Skip to content

Commit

Permalink
Fixed test case
Browse files Browse the repository at this point in the history
Signed-off-by: Aiham <[email protected]>
  • Loading branch information
aihamh committed Jun 28, 2024
1 parent e258dad commit 8c06c37
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 37 deletions.
11 changes: 6 additions & 5 deletions pre-registration-booking-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<pre.registration.core.version>1.2.1-java21-SNAPSHOT</pre.registration.core.version>
<kernel.core.version>1.2.1-java21-SNAPSHOT</kernel.core.version>
<kernel.bom.version>1.2.1-java21-SNAPSHOT</kernel.bom.version>
<java.version>21</java.version>
<!-- Core -->
<spring.boot.version>3.2.3</spring.boot.version>
<spring.data.version>2.0.9.RELEASE</spring.data.version>
Expand Down Expand Up @@ -102,6 +103,11 @@
<maven.sonar.plugin.version>3.7.0.1746</maven.sonar.plugin.version>
<maven.javadoc.version>3.2.0</maven.javadoc.version>

<!-- Test & Logging -->
<junit.version>4.12</junit.version>
<logback.version>1.1.6</logback.version>
<slf4j.version>1.7.19</slf4j.version>

</properties>

<dependencyManagement>
Expand Down Expand Up @@ -187,17 +193,14 @@
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>4.9</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>net.minidev</groupId>
Expand All @@ -207,12 +210,10 @@
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>net.minidev</groupId>
<artifactId>json-smart</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;

import io.mosip.preregistration.booking.config.BookingConfig;

/**
* This class is used to define the start of the Booking application.
*
Expand All @@ -33,6 +36,7 @@
"io\\.mosip\\.kernel\\.crypto\\..*",
"io\\.mosip\\.kernel\\.clientcrypto\\..*",
}) })
@EnableConfigurationProperties(BookingConfig.class)
public class BookingApplication {
/**
* Method to start the Booking API service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@
*/
package io.mosip.preregistration.booking.config;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.servers.Server;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springdoc.core.GroupedOpenApi;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.servers.Server;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@
import io.mosip.preregistration.core.util.DataValidationUtil;
import io.mosip.preregistration.core.util.RequestValidator;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import springfox.documentation.annotations.ApiIgnore;

/**
* This class provides different API's to perform operations on Booking
Expand Down Expand Up @@ -131,7 +131,7 @@ public ResponseEntity<MainResponseDTO<AvailabilityDto>> getAvailability(
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) })
public ResponseEntity<MainResponseDTO<BookingStatusDTO>> bookAppoinment(
@PathVariable("preRegistrationId") String preRegistrationId,
@Validated @RequestBody(required = true) MainRequestDTO<BookingRequestDTO> bookingDTO, @ApiIgnore Errors errors ) {
@Validated @RequestBody(required = true) MainRequestDTO<BookingRequestDTO> bookingDTO, @Parameter(hidden = true) Errors errors ) {
log.info("sessionId", "idType", "id",
"In bookAppoinment method of Booking controller to book an appointment for object: " + bookingDTO);
requestValidator.validateId(BOOKING, bookingDTO.getId(), errors);
Expand All @@ -157,7 +157,7 @@ public ResponseEntity<MainResponseDTO<BookingStatusDTO>> bookAppoinment(
@ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) })
public ResponseEntity<MainResponseDTO<BookingStatus>> bookMultiAppoinment(
@Validated @RequestBody(required = true) MainRequestDTO<MultiBookingRequest> bookingRequest, @ApiIgnore Errors errors) {
@Validated @RequestBody(required = true) MainRequestDTO<MultiBookingRequest> bookingRequest, @Parameter(hidden = true) Errors errors) {
log.info("sessionId", "idType", "id",
"In bookAppoinment method of Booking controller to book an appointment for object: " + bookingRequest);
requestValidator.validateId(BOOKING, bookingRequest.getId(), errors);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ public ResponseEntity<MainResponseDTO<?>> authServiceException(final Notificatio
List<ExceptionJSONInfoDTO> errorList = new ArrayList<>();
e.getValidationErrorList().stream().forEach(serviceError -> errorList
.add(new ExceptionJSONInfoDTO(serviceError.getErrorCode(), serviceError.getMessage())));
MainResponseDTO<?> errorRes = e.getMainResposneDTO();
MainResponseDTO<?> errorRes = e.getMainResponseDTO();
errorRes.setErrors(errorList);
errorRes.setResponsetime(GenericUtil.getCurrentResponseTime());
return new ResponseEntity<>(errorRes, HttpStatus.OK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,12 @@
import io.mosip.preregistration.booking.dto.RegistrationCenterResponseDto;
import io.mosip.preregistration.booking.dto.SlotDto;
import io.mosip.preregistration.booking.entity.AvailibityEntity;
import io.mosip.preregistration.booking.errorcodes.ErrorCodes;
import io.mosip.preregistration.booking.errorcodes.ErrorMessages;
import io.mosip.preregistration.booking.exception.AppointmentReBookingFailedException;
import io.mosip.preregistration.booking.exception.AvailablityNotFoundException;
import io.mosip.preregistration.booking.exception.BookingDateNotSeletectedException;
import io.mosip.preregistration.booking.exception.BookingPreIdNotFoundException;
import io.mosip.preregistration.booking.exception.BookingRegistrationCenterIdNotFoundException;
import io.mosip.preregistration.booking.exception.BookingTimeSlotNotSeletectedException;
import io.mosip.preregistration.booking.exception.DemographicGetStatusException;
import io.mosip.preregistration.booking.exception.InvalidDateTimeFormatException;
import io.mosip.preregistration.booking.exception.RecordNotFoundException;
import io.mosip.preregistration.booking.exception.TimeSpanException;
Expand All @@ -68,18 +65,15 @@
import io.mosip.preregistration.booking.repository.impl.BookingDAO;
import io.mosip.preregistration.booking.service.util.BookingServiceUtil;
import io.mosip.preregistration.core.common.dto.BookingRegistrationDTO;
import io.mosip.preregistration.core.common.dto.ExceptionJSONInfoDTO;
import io.mosip.preregistration.core.common.dto.MainRequestDTO;
import io.mosip.preregistration.core.common.dto.MainResponseDTO;
import io.mosip.preregistration.core.common.dto.NotificationDTO;
import io.mosip.preregistration.core.common.dto.PreRegistartionStatusDTO;
import io.mosip.preregistration.core.common.dto.ResponseWrapper;
import io.mosip.preregistration.core.exception.MasterDataNotAvailableException;
import io.mosip.preregistration.core.exception.RestCallException;
import io.mosip.preregistration.core.util.RequestValidator;

@RunWith(SpringRunner.class)
@SpringBootTest
@SpringBootTest(classes = { BookingServiceUtil.class })
public class BookingServiceUtilTest {

@MockBean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
javax.persistence.jdbc.driver=org.h2.Driver
javax.persistence.jdbc.url=jdbc:h2\:mem\:testdb;DB_CLOSE_DELAY=-1;INIT=RUNSCRIPT FROM 'classpath:create-schema.sql'
javax.persistence.jdbc.user=sa
javax.persistence.jdbc.password=
# javax.persistence.jdbc.driver=org.h2.Driver
# javax.persistence.jdbc.url=jdbc:h2\:mem\:testdb;DB_CLOSE_DELAY=-1;INIT=RUNSCRIPT FROM 'classpath:create-schema.sql'
# javax.persistence.jdbc.user=sa
javax.persistence.jdbc.driver: org.postgresql.Driver
javax.persistence.jdbc.url=jdbc:postgresql://api-internal.dev1.mosip.net:5432/mosip_prereg
javax.persistence.jdbc.user: postgres
javax.persistence.jdbc.password=aRWP1G52uu
mosip.kernel.objectstore.account-name=prereg
cancel.appoinment.template=cancel-appointment
hibernate.hbm2ddl.auto=update
Expand All @@ -13,10 +16,10 @@ hibernate.cache.use_second_level_cache=false
hibernate.cache.use_query_cache=false
hibernate.cache.use_structured_entries=false
hibernate.generate_statistics=false
notification.url=https://dev.mosip.net/notification/notify
notification.url=https://api-internal.dev1.mosip.net/notification/notify
mosip.supported-languages=eng,ara,fra
mosip.primary-language=eng
mosip.io.prid.url=https://dev.mosip.net/v1/pridgenerator/prid
mosip.io.prid.url=https://api-internal.dev1.mosip.net/v1/pridgenerator/prid
# preregistration.country.specific.zoneId=GMT+05:30
booking.resource.url=${dev.dns.url}/preregistration/v1
preregistration.rebook.timespan = 24
Expand Down Expand Up @@ -103,8 +106,8 @@ mosip.preregistration.booking.availability.increase.id=mosip.preregistration.boo
mosip.preregistration.booking.availability.check.id=mosip.preregistration.booking.availability.check
mosip.preregistration.booking.delete.old.id=mosip.preregistration.booking.delete.old
mosip.preregistration.booking.exception.id=mosip.preregistration.booking.parse.exception
mosip.kernel.idobjectvalidator.masterdata.documenttypes.rest.uri=https://dev.mosip.net/v1/masterdata/documenttypes/{documentcategorycode}/{langcode}
mosip.kernel.masterdata.validdoc.rest.uri==https://dev.mosip.net/masterdata/validdocuments/
mosip.kernel.idobjectvalidator.masterdata.documenttypes.rest.uri=https://api-internal.dev1.mosip.net/v1/masterdata/documenttypes/{documentcategorycode}/{langcode}
mosip.kernel.masterdata.validdoc.rest.uri==https://api-internal.dev1.mosip.net/masterdata/validdocuments/

mosip.preregistration.booking.id.book=mosip.preregistration.booking.book
# Name node url for HDFS
Expand Down Expand Up @@ -142,7 +145,7 @@ mosip.kernel.prid.restricted-numbers=786,666

mosip.kernel.virus-scanner.host=104.211.200.46
mosip.kernel.virus-scanner.port=3310
mosip.batch.token.authmanager.url= https://dev.mosip.net/v1/authmanager/authenticate/useridPwd
mosip.batch.token.authmanager.url= https://api-internal.dev1.mosip.net/v1/authmanager/authenticate/useridPwd
mosip.batch.token.authmanager.appId=ida
mosip.batch.token.authmanager.userName=110005
mosip.batch.token.authmanager.password=mosip
Expand All @@ -164,9 +167,10 @@ mosip.security.authentication.provider.beans.list=customJWTAuthProvider
mosip.kernel.auth.appids.realm.map={prereg:'preregistration',ida:'mosip',registrationclient:'mosip',regproc:'mosip',partner:'mosip',resident:'mosip',admin:'mosip',crereq:'mosip',creser:'mosip',datsha:'mosip'}
# To generate token from keycloak. Use by kernel auth adapter.
mosip.iam.adapter.clientid=mosip-prereg-client
mosip.iam.adapter.clientsecret=abc123
mosip.iam.adapter.clientsecret=lJmGIMqcfgsZiHh9
mosip.iam.adapter.appid=prereg
# URL to get new Auth Token from OIDC provider & to do online validation of auth token with OIDC provider.
auth.server.admin.issuer.uri=https://dev.mosip.net/keycloak/auth/realms/
# auth.server.admin.issuer.uri=https://api-internal.dev1.mosip.net/keycloak/auth/realms/
auth.server.admin.issuer.uri=https://iam.dev1.mosip.net/auth/realms/

spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER

0 comments on commit 8c06c37

Please sign in to comment.