diff --git a/build.gradle b/build.gradle index dc54e11d..ceb006d9 100644 --- a/build.gradle +++ b/build.gradle @@ -445,6 +445,10 @@ sourceSets { } } +test { + useJUnitPlatform() +} + dependencies { integrationTestImplementation(sourceSets.test.output) integrationTestAnnotationProcessor group: 'org.projectlombok', name: 'lombok', version: versions.lombok diff --git a/charts/prl-dgs/values.preview.template.yaml b/charts/prl-dgs/values.preview.template.yaml index ce1babe3..5c6cabc5 100644 --- a/charts/prl-dgs/values.preview.template.yaml +++ b/charts/prl-dgs/values.preview.template.yaml @@ -32,7 +32,7 @@ java: MANAGEMENT_ENDPOINT_HEALTH_CACHE_TIMETOLIVE: "30000" DOCMOSIS_SERVICE_DEV_MODE_FLAG: "true" PDF_TEST_ENABLED: "true" - CCD_CASE_DOCS_AM_API: http://prl-ccd-definitions-pr-2424-cdam + CCD_CASE_DOCS_AM_API: http://prl-ccd-definitions-pr-2170-cdam AUTH_PROVIDER_SERVICE_CLIENT_BASEURL: "http://rpe-service-auth-provider-{{ .Values.global.environment }}.service.core-compute-{{ .Values.global.environment }}.internal" IDAM_S2S_URL: "http://rpe-service-auth-provider-{{ .Values.global.environment }}.service.core-compute-{{ .Values.global.environment }}.internal" DOCMOSIS_SERVICE_BASE_URL: "https://docmosis.aat.platform.hmcts.net" diff --git a/src/contractTest/resources/application.yml b/src/contractTest/resources/application.yml index 0eb19600..69bb7e09 100644 --- a/src/contractTest/resources/application.yml +++ b/src/contractTest/resources/application.yml @@ -16,6 +16,7 @@ docmosis: uri: ${DOCMOSIS_SERVICE_BASE_URL:http://localhost:5501}${docmosis.service.pdf-service.renderEndpoint} convert: ${DOCMOSIS_SERVICE_BASE_URL:http://localhost:5501}${docmosis.service.pdf-service.convertEndpoint} health: ${DOCMOSIS_SERVICE_BASE_URL:http://localhost:5501}/health + convert: ${DOCMOSIS_SERVICE_BASE_URL:http://localhost:5501}${docmosis.service.pdf-service.convertEndpoint} devMode: ${DOCMOSIS_SERVICE_DEV_MODE_FLAG:false} case_document_am: diff --git a/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/controller/DocumentGeneratorController.java b/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/controller/DocumentGeneratorController.java index 6033d72a..3583c7a1 100644 --- a/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/controller/DocumentGeneratorController.java +++ b/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/controller/DocumentGeneratorController.java @@ -19,6 +19,7 @@ import uk.gov.hmcts.reform.prl.documentgenerator.domain.response.GeneratedDocumentInfo; import uk.gov.hmcts.reform.prl.documentgenerator.service.DocumentManagementService; +import java.io.IOException; import javax.validation.Valid; @RestController @@ -27,24 +28,26 @@ @Slf4j public class DocumentGeneratorController { + private final DocumentManagementService documentManagementService; + @Autowired - private DocumentManagementService documentManagementService; + public DocumentGeneratorController(DocumentManagementService documentManagementService) { + this.documentManagementService = documentManagementService; + } @Operation(description = "Generate PDF document based on the supplied template name and placeholder " - + "texts and saves it in the evidence management.", tags = {"Document Generation"}) - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "PDF was generated successfully and stored in the " - + "evidence management. Returns the url to the stored document.", content = - @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), - @ApiResponse(responseCode = "400", description = "Returned when input parameters are invalid " - + "or template not found", content = - @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), - @ApiResponse(responseCode = "503", description = "Returned when the PDF Service or Evidence " - + "Management Client Api cannot be reached", content = - @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), - @ApiResponse(responseCode = "500", description = "Returned when there is an unknown server error", - content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))) - }) + + "texts and saves it in the evidence management.", tags = {"Document Generation"}) + @ApiResponse(responseCode = "200", description = "PDF was generated successfully and stored in the " + + "evidence management. Returns the url to the stored document.", content = + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))) + @ApiResponse(responseCode = "400", description = "Returned when input parameters are invalid " + + "or template not found", content = + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))) + @ApiResponse(responseCode = "503", description = "Returned when the PDF Service or Evidence " + + "Management Client Api cannot be reached", content = + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))) + @ApiResponse(responseCode = "500", description = "Returned when there is an unknown server error", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))) @PostMapping("/generatePDF") public GeneratedDocumentInfo generateAndUploadPdf( @RequestHeader(value = "Authorization", required = false) @@ -63,19 +66,19 @@ public GeneratedDocumentInfo generateAndUploadPdf( @Operation(description = "Generate draft PDF document based on the supplied template name and placeholder texts " + "and saves it in the evidence management.", tags = {"Document Generation"}) - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "PDF was generated successfully and stored in the " - + "evidence management. Returns the url to the stored document.",content = - @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), - @ApiResponse(responseCode = "400", description = "Returned when input parameters are invalid or " - + "template not found", content = - @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), - @ApiResponse(responseCode = "503", description = "Returned when the PDF Service or Evidence Management " - + "Client Api cannot be reached", content = - @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), - @ApiResponse(responseCode = "500", description = "Returned when there is an unknown server error", - content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))) - }) + + @ApiResponse(responseCode = "200", description = "PDF was generated successfully and stored in the " + + "evidence management. Returns the url to the stored document.",content = + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))) + @ApiResponse(responseCode = "400", description = "Returned when input parameters are invalid or " + + "template not found", content = + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))) + @ApiResponse(responseCode = "503", description = "Returned when the PDF Service or Evidence Management " + + "Client Api cannot be reached", content = + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))) + @ApiResponse(responseCode = "500", description = "Returned when there is an unknown server error", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))) + @PostMapping("/generateDraftPDF") public GeneratedDocumentInfo generateAndUploadDraftPdf( @RequestHeader(value = "Authorization", required = false) @@ -103,7 +106,7 @@ public GeneratedDocumentInfo convertDocumentToPdf( + "templateName and the placeholder text map", required = true) @RequestBody @Valid - GenerateDocumentRequest templateData) { + GenerateDocumentRequest templateData) throws IOException { //This service is internal to Divorce system. No need to do service authentication here log.info("convertDocumentToPdf is getting called"); return documentManagementService.converToPdf( diff --git a/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/controller/helper/GlobalExceptionHandler.java b/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/controller/helper/GlobalExceptionHandler.java index 0a9358db..bdd6caa2 100644 --- a/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/controller/helper/GlobalExceptionHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/controller/helper/GlobalExceptionHandler.java @@ -31,13 +31,13 @@ public ResponseEntity handleTemplateLoadingException(ErrorLoadingTemplat public ResponseEntity handleDocumentStorageAndPDFGenerationException(Exception exception) { log.error(exception.getMessage(), exception); - if (exception.getCause() instanceof HttpClientErrorException) { - HttpStatus httpClientErrorException = ((HttpClientErrorException) exception.getCause()).getStatusCode(); + if (exception.getCause() instanceof HttpClientErrorException httpClientErrorException) { + HttpStatus httpClientStatus = httpClientErrorException.getStatusCode(); - if (httpClientErrorException == HttpStatus.BAD_REQUEST) { + if (httpClientStatus == HttpStatus.BAD_REQUEST) { return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE).body(exception.getMessage()); } else { - return ResponseEntity.status(httpClientErrorException).body(exception.getMessage()); + return ResponseEntity.status(httpClientStatus).body(exception.getMessage()); } } diff --git a/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/mapper/TemplateDataMapper.java b/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/mapper/TemplateDataMapper.java index 2fc66d3c..4be52b9a 100644 --- a/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/mapper/TemplateDataMapper.java +++ b/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/mapper/TemplateDataMapper.java @@ -21,8 +21,13 @@ @Component public class TemplateDataMapper { + + private final DocmosisBasePdfConfig docmosisBasePdfConfig; + @Autowired - private DocmosisBasePdfConfig docmosisBasePdfConfig; + public TemplateDataMapper(DocmosisBasePdfConfig docmosisBasePdfConfig) { + this.docmosisBasePdfConfig = docmosisBasePdfConfig; + } @SuppressWarnings("unchecked") public Map map(Map placeholders) { diff --git a/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/service/DocumentManagementService.java b/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/service/DocumentManagementService.java index 745edc15..0cece245 100644 --- a/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/service/DocumentManagementService.java +++ b/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/service/DocumentManagementService.java @@ -2,6 +2,7 @@ import uk.gov.hmcts.reform.prl.documentgenerator.domain.response.GeneratedDocumentInfo; +import java.io.IOException; import java.util.Map; public interface DocumentManagementService { @@ -15,5 +16,5 @@ GeneratedDocumentInfo generateAndStoreDraftDocument(String templateName, Map placeholders); - GeneratedDocumentInfo converToPdf(Map placeholders, String authorizationToken, String filename); + GeneratedDocumentInfo converToPdf(Map placeholders, String authorizationToken, String filename) throws IOException; } diff --git a/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/service/PDFGenerationService.java b/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/service/PDFGenerationService.java index a10d2795..2cafce61 100644 --- a/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/service/PDFGenerationService.java +++ b/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/service/PDFGenerationService.java @@ -1,11 +1,12 @@ package uk.gov.hmcts.reform.prl.documentgenerator.service; +import java.io.IOException; import java.util.Map; public interface PDFGenerationService { byte[] generate(String templateName, Map placeholders); - byte[] converToPdf(Map placeholders, String fileName); + byte[] converToPdf(Map placeholders, String fileName) throws IOException; } diff --git a/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/service/impl/DocmosisPDFGenerationServiceImpl.java b/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/service/impl/DocmosisPDFGenerationServiceImpl.java index 9cc11dd6..10a611aa 100644 --- a/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/service/impl/DocmosisPDFGenerationServiceImpl.java +++ b/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/service/impl/DocmosisPDFGenerationServiceImpl.java @@ -33,11 +33,15 @@ @Slf4j public class DocmosisPDFGenerationServiceImpl implements PDFGenerationService { - @Autowired - private RestTemplate restTemplate; + private final RestTemplate restTemplate; + + private final TemplateDataMapper templateDataMapper; @Autowired - private TemplateDataMapper templateDataMapper; + public DocmosisPDFGenerationServiceImpl(RestTemplate restTemplate,TemplateDataMapper templateDataMapper) { + this.restTemplate = restTemplate; + this.templateDataMapper = templateDataMapper; + } @Value("${docmosis.service.pdf-service.uri}") private String docmosisPdfServiceEndpoint; @@ -88,26 +92,19 @@ private PdfDocumentRequest request(String templateName, Map plac } @Override - public byte[] converToPdf(Map placeholders, String fileName) { - - try { - String filename = FilenameUtils.getBaseName(fileName) + ".pdf"; - ObjectMapper objectMapper = new ObjectMapper(); - byte[] docInBytes = objectMapper.convertValue(placeholders.get("fileName"), byte[].class); - File file = new File(fileName); - Files.write(docInBytes, file); - - return restTemplate - .postForObject( - docmosisPdfConvertEndpoint, - createRequest(file, filename), - byte[].class - ); - - } catch (IOException e) { - throw new RuntimeException(e); - } - + public byte[] converToPdf(Map placeholders, String fileName) throws IOException { + String filename = FilenameUtils.getBaseName(fileName) + ".pdf"; + ObjectMapper objectMapper = new ObjectMapper(); + byte[] docInBytes = objectMapper.convertValue(placeholders.get("fileName"), byte[].class); + File file = new File(fileName); + Files.write(docInBytes, file); + + return restTemplate + .postForObject( + docmosisPdfConvertEndpoint, + createRequest(file, filename), + byte[].class + ); } diff --git a/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/service/impl/DocumentManagementServiceImpl.java b/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/service/impl/DocumentManagementServiceImpl.java index b984c4c1..604e6b90 100644 --- a/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/service/impl/DocumentManagementServiceImpl.java +++ b/src/main/java/uk/gov/hmcts/reform/prl/documentgenerator/service/impl/DocumentManagementServiceImpl.java @@ -15,6 +15,7 @@ import uk.gov.hmcts.reform.prl.documentgenerator.service.DocumentManagementService; import uk.gov.hmcts.reform.prl.documentgenerator.service.PDFGenerationService; +import java.io.IOException; import java.text.SimpleDateFormat; import java.time.Clock; import java.util.Arrays; @@ -141,7 +142,7 @@ private String getCaseId(Map placeholders) { } @Override - public GeneratedDocumentInfo converToPdf(Map placeholders, String authorizationToken, String fileName) { + public GeneratedDocumentInfo converToPdf(Map placeholders, String authorizationToken, String fileName) throws IOException { log.debug( "Generate document requested with templateName [{}], placeholders of size[{}]", placeholders.size() diff --git a/src/test/java/uk/gov/hmcts/reform/prl/documentgenerator/controller/DocumentGeneratorControllerUTest.java b/src/test/java/uk/gov/hmcts/reform/prl/documentgenerator/controller/DocumentGeneratorControllerUTest.java index 99716ed7..fd657bff 100644 --- a/src/test/java/uk/gov/hmcts/reform/prl/documentgenerator/controller/DocumentGeneratorControllerUTest.java +++ b/src/test/java/uk/gov/hmcts/reform/prl/documentgenerator/controller/DocumentGeneratorControllerUTest.java @@ -9,6 +9,7 @@ import uk.gov.hmcts.reform.prl.documentgenerator.domain.response.GeneratedDocumentInfo; import uk.gov.hmcts.reform.prl.documentgenerator.service.DocumentManagementService; +import java.io.IOException; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -66,7 +67,7 @@ public void whenGeneratePDF_thenReturnGeneratedDraftPDFDocumentInfo() { } @Test - public void whenConvertPDF_thenReturnConvertedPDFDocumentInfo() { + public void whenConvertPDF_thenReturnConvertedPDFDocumentInfo() throws IOException { final String templateName = "templateName"; Map placeholder = new HashMap<>(); diff --git a/src/test/java/uk/gov/hmcts/reform/prl/documentgenerator/controller/helper/GlobalExceptionHandlerUTest.java b/src/test/java/uk/gov/hmcts/reform/prl/documentgenerator/controller/helper/GlobalExceptionHandlerUTest.java index 8cff87c5..b5f956da 100644 --- a/src/test/java/uk/gov/hmcts/reform/prl/documentgenerator/controller/helper/GlobalExceptionHandlerUTest.java +++ b/src/test/java/uk/gov/hmcts/reform/prl/documentgenerator/controller/helper/GlobalExceptionHandlerUTest.java @@ -1,8 +1,9 @@ package uk.gov.hmcts.reform.prl.documentgenerator.controller.helper; -import org.junit.Test; + +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; -import org.junit.runners.BlockJUnit4ClassRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.client.HttpClientErrorException; @@ -11,13 +12,13 @@ import static org.junit.Assert.assertEquals; -@RunWith(BlockJUnit4ClassRunner.class) -public class GlobalExceptionHandlerUTest { +@RunWith(MockitoJUnitRunner.class) +class GlobalExceptionHandlerUTest { private final GlobalExceptionHandler classUnderTest = new GlobalExceptionHandler(); @Test - public void whenHandleBadRequestException_thenReturnBadRequest() { + void whenHandleBadRequestException_thenReturnBadRequest() { final Exception exception = new Exception(); ResponseEntity response = classUnderTest.handleBadRequestException(exception); @@ -26,7 +27,7 @@ public void whenHandleBadRequestException_thenReturnBadRequest() { } @Test - public void whenHandleTemplateLoadingException_thenReturnBadRequest() { + void whenHandleTemplateLoadingException_thenReturnBadRequest() { final String message = "some message"; final Exception exception = new Exception(); final ErrorLoadingTemplateException errorLoadingTemplateException = @@ -39,7 +40,7 @@ public void whenHandleTemplateLoadingException_thenReturnBadRequest() { } @Test - public void givenHttpClientErrorExceptionWrappedIn_whenHandleDocumentStorageAndPDFGenerationException_thenReturnStatusCodeOfHttpClientErrorException() { + void givenHttpClientErrorExceptionWrappedIn_whenHandleDocumentStorageAndPDFGenerationException_thenReturnStatusCodeOfHttpClientErrorException() { final HttpStatus httpStatus = HttpStatus.MOVED_PERMANENTLY; final HttpClientErrorException httpClientErrorException = new HttpClientErrorException(httpStatus); @@ -56,7 +57,7 @@ public void givenHttpClientErrorExceptionWrappedIn_whenHandleDocumentStorageAndP } @Test - public void givenHttpClientErrorResponseCode200_whenHandleDocumentStorageAndPDFGenerationException_thenReturnStatus503() { + void givenHttpClientErrorResponseCode200_whenHandleDocumentStorageAndPDFGenerationException_thenReturnStatus503() { final HttpStatus httpStatus = HttpStatus.BAD_REQUEST; final HttpClientErrorException httpClientErrorException = new HttpClientErrorException(httpStatus); @@ -73,7 +74,7 @@ public void givenHttpClientErrorResponseCode200_whenHandleDocumentStorageAndPDFG } @Test - public void givenWrappedInExceptionIsNull_whenHandleDocumentStorageAndPDFGenerationException_thenReturnInternalServerError() { + void givenWrappedInExceptionIsNull_whenHandleDocumentStorageAndPDFGenerationException_thenReturnInternalServerError() { final String message = "some message"; PDFGenerationException pdfGenerationException = new PDFGenerationException(message, null); @@ -86,7 +87,7 @@ public void givenWrappedInExceptionIsNull_whenHandleDocumentStorageAndPDFGenerat } @Test - public void givenWrappedInIsNotHttpClientErrorException_whenHandleDocumentStorageAndPDFGenerationException_thenReturnInternalServerError() { + void givenWrappedInIsNotHttpClientErrorException_whenHandleDocumentStorageAndPDFGenerationException_thenReturnInternalServerError() { final String message = "some message"; final Exception exception = new Exception(); diff --git a/src/test/java/uk/gov/hmcts/reform/prl/documentgenerator/functionaltest/DocumentGenerateAndStoreE2ETest.java b/src/test/java/uk/gov/hmcts/reform/prl/documentgenerator/functionaltest/DocumentGenerateAndStoreE2ETest.java index ac94c667..746385de 100644 --- a/src/test/java/uk/gov/hmcts/reform/prl/documentgenerator/functionaltest/DocumentGenerateAndStoreE2ETest.java +++ b/src/test/java/uk/gov/hmcts/reform/prl/documentgenerator/functionaltest/DocumentGenerateAndStoreE2ETest.java @@ -5,6 +5,10 @@ import org.junit.ClassRule; import org.junit.Ignore; import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; +import org.junit.jupiter.params.provider.NullSource; +import org.junit.jupiter.params.provider.ValueSource; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; @@ -68,37 +72,10 @@ public class DocumentGenerateAndStoreE2ETest { @ClassRule public static WireMockClassRule serviceAuthServer = new WireMockClassRule(4502); - @Test - public void givenTemplateNameIsNull_whenGenerateAndStoreDocument_thenReturnHttp400() throws Exception { - final String template = null; - final Map values = Collections.emptyMap(); - - final GenerateDocumentRequest generateDocumentRequest = new GenerateDocumentRequest(template, values); - - webClient.perform(post(API_URL) - .content(ObjectMapperTestUtil.convertObjectToJsonString(generateDocumentRequest)) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isBadRequest()); - } - - @Test - public void givenTemplateNameIsBlank_whenGenerateAndStoreDocument_thenReturnHttp400() throws Exception { - final String template = " "; - final Map values = Collections.emptyMap(); - - final GenerateDocumentRequest generateDocumentRequest = new GenerateDocumentRequest(template, values); - - webClient.perform(post(API_URL) - .content(ObjectMapperTestUtil.convertObjectToJsonString(generateDocumentRequest)) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isBadRequest()); - } - - @Test - public void givenTemplateNotFound_whenGenerateAndStoreDocument_thenReturnHttp400() throws Exception { - final String template = "nonExistingTemplate"; + @ParameterizedTest + @NullSource + @ValueSource(strings = {" ", "nonExistingTemplate"}) + void givenTemplateNameIsNull_whenGenerateAndStoreDocument_thenReturnHttp400(String template) throws Exception { final Map values = Collections.emptyMap(); final GenerateDocumentRequest generateDocumentRequest = new GenerateDocumentRequest(template, values); diff --git a/src/test/java/uk/gov/hmcts/reform/prl/documentgenerator/service/impl/DocmosisPdfGenerationServiceImplUTest.java b/src/test/java/uk/gov/hmcts/reform/prl/documentgenerator/service/impl/DocmosisPdfGenerationServiceImplUTest.java index 9df07550..db34eba5 100644 --- a/src/test/java/uk/gov/hmcts/reform/prl/documentgenerator/service/impl/DocmosisPdfGenerationServiceImplUTest.java +++ b/src/test/java/uk/gov/hmcts/reform/prl/documentgenerator/service/impl/DocmosisPdfGenerationServiceImplUTest.java @@ -50,7 +50,8 @@ public class DocmosisPdfGenerationServiceImplUTest { @InjectMocks @Spy - private final DocmosisPDFGenerationServiceImpl classUnderTest = new DocmosisPDFGenerationServiceImpl(); + private final DocmosisPDFGenerationServiceImpl classUnderTest = new + DocmosisPDFGenerationServiceImpl(restTemplate,templateDataMapper); @Before public void before() throws IllegalAccessException { diff --git a/src/test/java/uk/gov/hmcts/reform/prl/documentgenerator/service/impl/DocumentManagementServiceImplTest.java b/src/test/java/uk/gov/hmcts/reform/prl/documentgenerator/service/impl/DocumentManagementServiceImplTest.java index 3b24f7bf..fc47b84a 100644 --- a/src/test/java/uk/gov/hmcts/reform/prl/documentgenerator/service/impl/DocumentManagementServiceImplTest.java +++ b/src/test/java/uk/gov/hmcts/reform/prl/documentgenerator/service/impl/DocumentManagementServiceImplTest.java @@ -15,6 +15,7 @@ import uk.gov.hmcts.reform.prl.documentgenerator.config.TemplatesConfiguration; import uk.gov.hmcts.reform.prl.documentgenerator.service.PDFGenerationService; +import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -110,7 +111,7 @@ public void testGenerateAndStoreDraftDocument_WithDraftPrefixMock() { } @Test - public void testConvertToPdf() { + public void testConvertToPdf() throws IOException { final Map placeholders = new HashMap<>(); byte[] test = "Any String you want".getBytes(); diff --git a/src/test/java/uk/gov/hmcts/reform/prl/documentgenerator/util/NullOrEmptyValidatorUTest.java b/src/test/java/uk/gov/hmcts/reform/prl/documentgenerator/util/NullOrEmptyValidatorUTest.java index fbed4f23..d28e0ad8 100644 --- a/src/test/java/uk/gov/hmcts/reform/prl/documentgenerator/util/NullOrEmptyValidatorUTest.java +++ b/src/test/java/uk/gov/hmcts/reform/prl/documentgenerator/util/NullOrEmptyValidatorUTest.java @@ -28,13 +28,11 @@ public void testConstructorPrivate() throws Exception { } @Test(expected = IllegalArgumentException.class) - @Ignore public void givenArrayIsNull_whenRequireNonEmpty_thenThrowsIllegalArgumentException() { NullOrEmptyValidator.requireNonEmpty(null); } @Test(expected = IllegalArgumentException.class) - @Ignore public void givenArrayIsEmpty_whenRequireNonEmpty_thenThrowsIllegalArgumentException() { NullOrEmptyValidator.requireNonEmpty(ArrayUtils.EMPTY_BYTE_ARRAY); } @@ -49,19 +47,16 @@ public void givenArrayIsNotEmptyOrNull_whenRequireNonEmpty_thenDoesNotThrowExcep } @Test(expected = IllegalArgumentException.class) - @Ignore public void givenTextIsNull_whenRequireNonBlank_thenThrowsIllegalArgumentException() { NullOrEmptyValidator.requireNonBlank(null); } @Test(expected = IllegalArgumentException.class) - @Ignore public void givenTextIsEmpty_whenRequireNonBlank_thenThrowsIllegalArgumentException() { NullOrEmptyValidator.requireNonBlank(EMPTY_STRING); } @Test(expected = IllegalArgumentException.class) - @Ignore public void givenTextIsBlank_whenRequireNonBlank_thenThrowsIllegalArgumentException() { NullOrEmptyValidator.requireNonBlank(BLANK_STRING); }