From fae271d09fc683677f03c2c0f311e28fbf481363 Mon Sep 17 00:00:00 2001 From: Artemas-Muzanenhamo Date: Sun, 24 Mar 2024 09:45:25 +0000 Subject: [PATCH] upgrade license-service to Spring Boot 2.2.9 --- license-service/build.gradle | 67 ++++----- license-service/gradle.properties | 22 +-- .../src/main/java/com/gov/zw/DBSeeder.java | 2 +- .../com/gov/zw/client/IdentityClient.java | 4 +- .../gov/zw/client/IdentityReferenceJson.java | 7 +- .../gov/zw/client/dto/IdentityReference.java | 7 +- ...dentityReferenceJsonNotValidException.java | 2 - .../gov/zw/controller/LicenseController.java | 21 ++- .../main/java/com/gov/zw/domain/License.java | 130 +++++++++++++++++ .../src/main/java/com/gov/zw/dto/License.java | 89 ------------ .../exception/InvalidIdentityException.java | 2 +- .../zw/exception/InvalidLicenseException.java | 2 +- .../gov/zw/{domain => json}/LicenseJson.java | 19 +-- .../java/com/gov/zw/mapper/LicenseMapper.java | 4 +- .../gov/zw/repository/LicenseRepository.java | 3 +- .../com/gov/zw/service/LicenseService.java | 2 +- .../gov/zw/service/LicenseServiceImpl.java | 2 +- .../zw/LicenseServiceApplicationTests.java | 3 - .../com/gov/zw/client/IdentityClientTest.java | 7 +- .../zw/controller/LicenseControllerTest.java | 25 ++-- .../controller/LicenseControllerUnitTest.java | 132 ------------------ .../com/gov/zw/domain/LicenseJsonTest.java | 47 ------- .../test/java/com/gov/zw/dto/LicenseTest.java | 77 ---------- .../com/gov/zw/mapper/LicenseMapperTest.java | 6 +- .../zw/repository/LicenseRepositoryTest.java | 5 +- .../gov/zw/service/LicenseServiceTest.java | 10 +- pacts/license-service-identity-service.json | 2 +- 27 files changed, 217 insertions(+), 482 deletions(-) create mode 100644 license-service/src/main/java/com/gov/zw/domain/License.java delete mode 100644 license-service/src/main/java/com/gov/zw/dto/License.java rename license-service/src/main/java/com/gov/zw/{domain => json}/LicenseJson.java (84%) delete mode 100644 license-service/src/test/java/com/gov/zw/controller/LicenseControllerUnitTest.java delete mode 100644 license-service/src/test/java/com/gov/zw/domain/LicenseJsonTest.java delete mode 100644 license-service/src/test/java/com/gov/zw/dto/LicenseTest.java diff --git a/license-service/build.gradle b/license-service/build.gradle index 00b6bbec..8e6c9bd8 100644 --- a/license-service/build.gradle +++ b/license-service/build.gradle @@ -1,44 +1,50 @@ plugins { + id 'idea' id 'java' - id 'maven' id 'jacoco' - id 'org.springframework.boot' version '2.0.4.RELEASE' + id 'org.springframework.boot' version '2.2.9.RELEASE' + id 'io.spring.dependency-management' version '1.1.4' } +group = 'com.gov.zw' +version = "${releaseVersion}" +description = 'license-service' +sourceCompatibility = 11 +targetCompatibility = 11 + +apply plugin: 'io.spring.dependency-management' + repositories { mavenCentral() } dependencies { - compile "org.springframework.boot:spring-boot-starter-data-mongodb:${springVersion}" - compile "org.springframework.boot:spring-boot-starter-web:${springVersion}" - compile "org.springframework.cloud:spring-cloud-starter-netflix-eureka-client:${springVersion}" - compile "org.springframework.boot:spring-boot-starter-actuator:${springVersion}" - compile "org.springframework.boot:spring-boot-starter-data-rest:${springVersion}" - compile "org.springframework.cloud:spring-cloud-starter-config:${springVersion}" - compile "org.springframework.cloud:spring-cloud-starter-openfeign:${springVersion}" - compile "org.springframework.cloud:spring-cloud-openfeign-core:${springVersion}" - compile "org.springframework.cloud:spring-cloud-openfeign-dependencies:${springVersion}" - compile "org.springframework.cloud:spring-cloud-contract-spec:${springVersion}" - compile "org.springframework.cloud:spring-cloud-netflix-core:${springVersion}" - compile "org.springframework.cloud:spring-cloud-starter-netflix-ribbon:${springVersion}" - compile "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" - compile "org.apache.httpcomponents:httpclient:${httpClientVersion}" - compile "com.google.code.gson:gson:${gsonVersion}" - compile "io.springfox:springfox-swagger2:2.9.2" - compile "io.springfox:springfox-swagger-ui:2.9.2" + implementation "org.springframework.boot:spring-boot-starter-data-mongodb" + implementation "org.springframework.boot:spring-boot-starter-web" + implementation "org.springframework.cloud:spring-cloud-starter-netflix-eureka-client" + implementation "org.springframework.boot:spring-boot-starter-actuator" + implementation "org.springframework.boot:spring-boot-starter-data-rest" + implementation "org.springframework.cloud:spring-cloud-starter-config" + implementation "org.springframework.cloud:spring-cloud-starter-openfeign" + implementation "org.springframework.cloud:spring-cloud-openfeign-core" + implementation "org.springframework.cloud:spring-cloud-netflix-core" + implementation "org.springframework.cloud:spring-cloud-starter-netflix-ribbon" + implementation "io.springfox:springfox-boot-starter:3.0.0" + implementation "io.springfox:springfox-swagger-ui:3.0.0" compileOnly "org.projectlombok:lombok:${lombokVersion}" annotationProcessor "org.projectlombok:lombok:${lombokVersion}" - testCompileOnly "org.projectlombok:lombok:${lombokVersion}" - testCompile "org.junit.jupiter:junit-jupiter-engine:${junit5Version}" - testCompile "org.springframework:spring-test:${springTestVersion}" - testCompile "org.junit.jupiter:junit-jupiter-api:${junit5Version}" - testCompile "de.flapdoodle.embed:de.flapdoodle.embed.mongo:${mongoVersion}" - testCompile "org.springframework.boot:spring-boot-starter-test:${springVersion}" - testCompile "au.com.dius:pact-jvm-consumer-junit5_2.12:${pactJunit5Version}" - testCompile "io.rest-assured:rest-assured:${restAssuredVersion}" - testCompile "org.mockito:mockito-junit-jupiter:${mockitoJunit5Version}" + testImplementation "org.springframework.boot:spring-boot-starter-test" + testImplementation "de.flapdoodle.embed:de.flapdoodle.embed.mongo:${mongoVersion}" + testImplementation "au.com.dius:pact-jvm-consumer-junit5_2.12:${pactJunit5Version}" + testImplementation "com.jayway.restassured:rest-assured:${restAssuredVersion}" +} + + +dependencyManagement { + imports { + mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" + } } bootRun { @@ -49,11 +55,6 @@ test { systemProperty 'pact.rootDir', "../pacts" } -group = 'com.gov.zw' -version = "${releaseVersion}" -description = 'license-service' -sourceCompatibility = "${javaVersion}" - tasks.withType(JavaCompile) { options.encoding = "${charset}" } diff --git a/license-service/gradle.properties b/license-service/gradle.properties index e2cbbef1..e8c2605b 100644 --- a/license-service/gradle.properties +++ b/license-service/gradle.properties @@ -1,34 +1,16 @@ #Spring -springVersion=2.0.4.RELEASE -springTestVersion=5.1.8.RELEASE -springCloudVersion=Finchley.RELEASE -springCloudServicesVersion=2.0.3.RELEASE -springJdbcVersion=4.3.9.RELEASE -reactorTestVersion=3.1.7.RELEASE +springCloudVersion=Hoxton.RELEASE #Lombok lombokVersion=1.18.8 -#Junit5 -junit5Version=5.4.2 #Pact pactJunit5Version=3.6.11 #RestAssured -restAssuredVersion=4.0.0 +restAssuredVersion=2.9.0 #Embedded Mongo mongoVersion=4.12.2 #HttpClient httpClientVersion=4.5.9 -#Gson -gsonVersion=2.8.5 -#Java -javaVersion=1.8 -javaXmlVersion=2.3.0 #Application releaseVersion=1.0.1 #Encoding charset=UTF-8 -#Mockito -mockitoJunit5Version=3.0.0 -#Json -jsonSmartVersion=2.3 -#Rest Client Drive -restClientDriverVersion=2.0.0 diff --git a/license-service/src/main/java/com/gov/zw/DBSeeder.java b/license-service/src/main/java/com/gov/zw/DBSeeder.java index 4e6e166e..ec2681b6 100644 --- a/license-service/src/main/java/com/gov/zw/DBSeeder.java +++ b/license-service/src/main/java/com/gov/zw/DBSeeder.java @@ -1,6 +1,6 @@ package com.gov.zw; -import com.gov.zw.dto.License; +import com.gov.zw.domain.License; import com.gov.zw.repository.LicenseRepository; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Component; diff --git a/license-service/src/main/java/com/gov/zw/client/IdentityClient.java b/license-service/src/main/java/com/gov/zw/client/IdentityClient.java index 9a94c52d..85d3332c 100644 --- a/license-service/src/main/java/com/gov/zw/client/IdentityClient.java +++ b/license-service/src/main/java/com/gov/zw/client/IdentityClient.java @@ -8,10 +8,12 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; + @FeignClient(name = "identity-service") @Component public interface IdentityClient { - @PostMapping(value = "/identities/reference", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @PostMapping(value = "/identities/reference", produces = APPLICATION_JSON_VALUE) Identity findIdentityByIdReferenceNumber(@RequestBody IdentityReference identityReference); } diff --git a/license-service/src/main/java/com/gov/zw/client/IdentityReferenceJson.java b/license-service/src/main/java/com/gov/zw/client/IdentityReferenceJson.java index 50a34192..66f0ec6c 100644 --- a/license-service/src/main/java/com/gov/zw/client/IdentityReferenceJson.java +++ b/license-service/src/main/java/com/gov/zw/client/IdentityReferenceJson.java @@ -1,7 +1,10 @@ package com.gov.zw.client; +import lombok.Getter; + import java.util.Objects; +@Getter public class IdentityReferenceJson { public String idRef; @@ -11,10 +14,6 @@ public IdentityReferenceJson(String idRef) { this.idRef = idRef; } - public String getIdRef() { - return idRef; - } - @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/license-service/src/main/java/com/gov/zw/client/dto/IdentityReference.java b/license-service/src/main/java/com/gov/zw/client/dto/IdentityReference.java index b5784bdd..c54ce367 100644 --- a/license-service/src/main/java/com/gov/zw/client/dto/IdentityReference.java +++ b/license-service/src/main/java/com/gov/zw/client/dto/IdentityReference.java @@ -1,7 +1,10 @@ package com.gov.zw.client.dto; +import lombok.Getter; + import java.util.Objects; +@Getter public class IdentityReference { private final String idRef; @@ -9,10 +12,6 @@ public IdentityReference(String idRef) { this.idRef = idRef; } - public String getIdRef() { - return idRef; - } - @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/license-service/src/main/java/com/gov/zw/client/exception/IdentityReferenceJsonNotValidException.java b/license-service/src/main/java/com/gov/zw/client/exception/IdentityReferenceJsonNotValidException.java index bb25130e..48fcf523 100644 --- a/license-service/src/main/java/com/gov/zw/client/exception/IdentityReferenceJsonNotValidException.java +++ b/license-service/src/main/java/com/gov/zw/client/exception/IdentityReferenceJsonNotValidException.java @@ -1,8 +1,6 @@ package com.gov.zw.client.exception; public class IdentityReferenceJsonNotValidException extends RuntimeException { - public IdentityReferenceJsonNotValidException() { - } public IdentityReferenceJsonNotValidException(String message) { super(message); diff --git a/license-service/src/main/java/com/gov/zw/controller/LicenseController.java b/license-service/src/main/java/com/gov/zw/controller/LicenseController.java index dc7a1384..2e82a962 100644 --- a/license-service/src/main/java/com/gov/zw/controller/LicenseController.java +++ b/license-service/src/main/java/com/gov/zw/controller/LicenseController.java @@ -2,8 +2,8 @@ import com.gov.zw.client.IdentityReferenceJson; import com.gov.zw.client.dto.IdentityReference; -import com.gov.zw.domain.LicenseJson; -import com.gov.zw.dto.License; +import com.gov.zw.json.LicenseJson; +import com.gov.zw.domain.License; import com.gov.zw.service.LicenseService; import com.gov.zw.exception.InvalidIdentityException; import com.gov.zw.exception.InvalidLicenseException; @@ -14,7 +14,7 @@ import static com.gov.zw.mapper.IdentityReferenceMapper.toIdentityReferenceDTO; import static com.gov.zw.mapper.LicenseMapper.*; import static org.springframework.http.HttpStatus.OK; -import static org.springframework.http.MediaType.APPLICATION_JSON_UTF8_VALUE; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @RestController @RequestMapping("/licenses") @@ -26,39 +26,34 @@ public LicenseController(LicenseService licenseServiceImpl) { this.licenseServiceImpl = licenseServiceImpl; } - @PostMapping(produces = APPLICATION_JSON_UTF8_VALUE) - @ResponseBody + @PostMapping(produces = APPLICATION_JSON_VALUE) @ResponseStatus(value = OK) public void addLicense(@RequestBody LicenseJson licenseJson) throws InvalidLicenseException, InvalidIdentityException { License license = toLicenseDTO(licenseJson); this.licenseServiceImpl.addLicense(license); } - @GetMapping(produces = APPLICATION_JSON_UTF8_VALUE) - @ResponseBody + @GetMapping(produces = APPLICATION_JSON_VALUE) public List getAllLicenses() { List licenses = this.licenseServiceImpl.getAllLicenses(); return toLicenseJsonList(licenses); } - @PostMapping(produces = APPLICATION_JSON_UTF8_VALUE, value = "ref") - @ResponseBody + @PostMapping(produces = APPLICATION_JSON_VALUE, value = "ref") public LicenseJson getLicenseByIdentityRef(@RequestBody IdentityReferenceJson identityReferenceJson) throws InvalidLicenseException { IdentityReference identityReference = toIdentityReferenceDTO(identityReferenceJson); License license = this.licenseServiceImpl.getLicenseByIdentityRef(identityReference); return toLicenseJson(license); } - @PutMapping(produces = APPLICATION_JSON_UTF8_VALUE) - @ResponseBody + @PutMapping(produces = APPLICATION_JSON_VALUE) @ResponseStatus(value = OK) public void updateLicense(@RequestBody LicenseJson licenseJson) throws InvalidLicenseException { License license = toLicenseDTO(licenseJson); this.licenseServiceImpl.updateLicense(license); } - @DeleteMapping(produces = APPLICATION_JSON_UTF8_VALUE) - @ResponseBody + @DeleteMapping(produces = APPLICATION_JSON_VALUE) @ResponseStatus(value = OK) public void deleteLicense(@RequestBody LicenseJson licenseJson) throws InvalidLicenseException { License license = toLicenseDTO(licenseJson); diff --git a/license-service/src/main/java/com/gov/zw/domain/License.java b/license-service/src/main/java/com/gov/zw/domain/License.java new file mode 100644 index 00000000..c1183d8b --- /dev/null +++ b/license-service/src/main/java/com/gov/zw/domain/License.java @@ -0,0 +1,130 @@ +package com.gov.zw.domain; + +import org.springframework.data.annotation.Id; +import org.springframework.data.mongodb.core.mapping.Document; + +import java.util.Objects; + +@Document(collection = "Licenses") +public class License { + + @Id + private String id; + private String identityRef; + private String surname; + private String firstNames; + private String dateOfBirth; + private String country; + private String dateOfIssue; + private String expiryDate; + private String agency; + private String licenseNumber; + private String signatureImage; + private String address; + + public License() {} + + public License(String id, String identityRef, String surname, String firstNames, String dateOfBirth, String country, + String dateOfIssue, String expiryDate, String agency, String licenseNumber, + String signatureImage, String address) { + this.id = id; + this.identityRef = identityRef; + this.surname = surname; + this.firstNames = firstNames; + this.dateOfBirth = dateOfBirth; + this.country = country; + this.dateOfIssue = dateOfIssue; + this.expiryDate = expiryDate; + this.agency = agency; + this.licenseNumber = licenseNumber; + this.signatureImage = signatureImage; + this.address = address; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getIdentityRef() { + return identityRef; + } + + public void setIdentityRef(String identityRef) { + this.identityRef = identityRef; + } + + public String getSurname() { + return surname; + } + + public String getFirstNames() { + return firstNames; + } + + public String getDateOfBirth() { + return dateOfBirth; + } + + public String getCountry() { + return country; + } + + public String getDateOfIssue() { + return dateOfIssue; + } + + public String getExpiryDate() { + return expiryDate; + } + + public String getAgency() { + return agency; + } + + public String getLicenseNumber() { + return licenseNumber; + } + + public String getSignatureImage() { + return signatureImage; + } + + public String getAddress() { + return address; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + License license = (License) o; + return Objects.equals(id, license.id) && Objects.equals(identityRef, license.identityRef) && Objects.equals(surname, license.surname) && Objects.equals(firstNames, license.firstNames) && Objects.equals(dateOfBirth, license.dateOfBirth) && Objects.equals(country, license.country) && Objects.equals(dateOfIssue, license.dateOfIssue) && Objects.equals(expiryDate, license.expiryDate) && Objects.equals(agency, license.agency) && Objects.equals(licenseNumber, license.licenseNumber) && Objects.equals(signatureImage, license.signatureImage) && Objects.equals(address, license.address); + } + + @Override + public int hashCode() { + return Objects.hash(id, identityRef, surname, firstNames, dateOfBirth, country, dateOfIssue, expiryDate, agency, licenseNumber, signatureImage, address); + } + + @Override + public String toString() { + return "License{" + + "id='" + id + '\'' + + ", identityRef='" + identityRef + '\'' + + ", surname='" + surname + '\'' + + ", firstNames='" + firstNames + '\'' + + ", dateOfBirth='" + dateOfBirth + '\'' + + ", country='" + country + '\'' + + ", dateOfIssue='" + dateOfIssue + '\'' + + ", expiryDate='" + expiryDate + '\'' + + ", agency='" + agency + '\'' + + ", licenseNumber='" + licenseNumber + '\'' + + ", signatureImage='" + signatureImage + '\'' + + ", address='" + address + '\'' + + '}'; + } +} diff --git a/license-service/src/main/java/com/gov/zw/dto/License.java b/license-service/src/main/java/com/gov/zw/dto/License.java deleted file mode 100644 index ae94871a..00000000 --- a/license-service/src/main/java/com/gov/zw/dto/License.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.gov.zw.dto; - -import lombok.*; -import org.springframework.data.annotation.Id; -import org.springframework.data.mongodb.core.mapping.Document; - -@Document(collection = "Licenses") -@Data -public class License { - - @Id - private String id; - private String identityRef; - private String surname; - private String firstNames; - private String dateOfBirth; - private String country; - private String dateOfIssue; - private String expiryDate; - private String agency; - private String licenseNumber; - private String signatureImage; - private String address; - - public License() { } - - public License(String id, String identityRef, String surname, String firstNames, String dateOfBirth, String country, String dateOfIssue, String expiryDate, String agency, String licenseNumber, String signatureImage, String address) { - this.id = id; - this.identityRef = identityRef; - this.surname = surname; - this.firstNames = firstNames; - this.dateOfBirth = dateOfBirth; - this.country = country; - this.dateOfIssue = dateOfIssue; - this.expiryDate = expiryDate; - this.agency = agency; - this.licenseNumber = licenseNumber; - this.signatureImage = signatureImage; - this.address = address; - } - - public String getId() { - return id; - } - - public String getIdentityRef() { - return identityRef; - } - - public String getSurname() { - return surname; - } - - public String getFirstNames() { - return firstNames; - } - - public String getDateOfBirth() { - return dateOfBirth; - } - - public String getCountry() { - return country; - } - - public String getDateOfIssue() { - return dateOfIssue; - } - - public String getExpiryDate() { - return expiryDate; - } - - public String getAgency() { - return agency; - } - - public String getLicenseNumber() { - return licenseNumber; - } - - public String getSignatureImage() { - return signatureImage; - } - - public String getAddress() { - return address; - } -} diff --git a/license-service/src/main/java/com/gov/zw/exception/InvalidIdentityException.java b/license-service/src/main/java/com/gov/zw/exception/InvalidIdentityException.java index 48b13a00..02cd7bfb 100644 --- a/license-service/src/main/java/com/gov/zw/exception/InvalidIdentityException.java +++ b/license-service/src/main/java/com/gov/zw/exception/InvalidIdentityException.java @@ -2,7 +2,7 @@ public class InvalidIdentityException extends Exception { - static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; public InvalidIdentityException(String message){ super(message); diff --git a/license-service/src/main/java/com/gov/zw/exception/InvalidLicenseException.java b/license-service/src/main/java/com/gov/zw/exception/InvalidLicenseException.java index d6c094de..c57fd583 100644 --- a/license-service/src/main/java/com/gov/zw/exception/InvalidLicenseException.java +++ b/license-service/src/main/java/com/gov/zw/exception/InvalidLicenseException.java @@ -2,7 +2,7 @@ public class InvalidLicenseException extends Exception { - static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; public InvalidLicenseException(String message){ super(message); diff --git a/license-service/src/main/java/com/gov/zw/domain/LicenseJson.java b/license-service/src/main/java/com/gov/zw/json/LicenseJson.java similarity index 84% rename from license-service/src/main/java/com/gov/zw/domain/LicenseJson.java rename to license-service/src/main/java/com/gov/zw/json/LicenseJson.java index 2f907563..f00a7bf0 100644 --- a/license-service/src/main/java/com/gov/zw/domain/LicenseJson.java +++ b/license-service/src/main/java/com/gov/zw/json/LicenseJson.java @@ -1,6 +1,4 @@ -package com.gov.zw.domain; - -import com.gov.zw.dto.License; +package com.gov.zw.json; import java.util.Objects; @@ -36,21 +34,6 @@ public LicenseJson(String id, String identityRef, String surname, String firstNa this.address = address; } - public LicenseJson(License license) { - this.id = license.getId(); - this.identityRef = license.getIdentityRef(); - this.surname = license.getSurname(); - this.firstNames = license.getFirstNames(); - this.dateOfBirth = license.getDateOfBirth(); - this.country = license.getCountry(); - this.dateOfIssue = license.getDateOfIssue(); - this.expiryDate = license.getExpiryDate(); - this.agency = license.getAgency(); - this.licenseNumber = license.getLicenseNumber(); - this.signatureImage = license.getSignatureImage(); - this.address = license.getAddress(); - } - public String getId() { return id; } diff --git a/license-service/src/main/java/com/gov/zw/mapper/LicenseMapper.java b/license-service/src/main/java/com/gov/zw/mapper/LicenseMapper.java index 53b0e641..ed3906bd 100644 --- a/license-service/src/main/java/com/gov/zw/mapper/LicenseMapper.java +++ b/license-service/src/main/java/com/gov/zw/mapper/LicenseMapper.java @@ -1,7 +1,7 @@ package com.gov.zw.mapper; -import com.gov.zw.domain.LicenseJson; -import com.gov.zw.dto.License; +import com.gov.zw.json.LicenseJson; +import com.gov.zw.domain.License; import java.util.Collection; import java.util.List; diff --git a/license-service/src/main/java/com/gov/zw/repository/LicenseRepository.java b/license-service/src/main/java/com/gov/zw/repository/LicenseRepository.java index 0116a2f5..287b4864 100644 --- a/license-service/src/main/java/com/gov/zw/repository/LicenseRepository.java +++ b/license-service/src/main/java/com/gov/zw/repository/LicenseRepository.java @@ -1,12 +1,11 @@ package com.gov.zw.repository; -import com.gov.zw.dto.License; +import com.gov.zw.domain.License; import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.repository.query.Param; import java.util.List; public interface LicenseRepository extends MongoRepository { - List findLicensesByFirstNames(@Param("name") String name); License findLicenseByIdentityRef(String identityRef); } diff --git a/license-service/src/main/java/com/gov/zw/service/LicenseService.java b/license-service/src/main/java/com/gov/zw/service/LicenseService.java index 2685d47b..b198aa86 100644 --- a/license-service/src/main/java/com/gov/zw/service/LicenseService.java +++ b/license-service/src/main/java/com/gov/zw/service/LicenseService.java @@ -1,7 +1,7 @@ package com.gov.zw.service; import com.gov.zw.client.dto.IdentityReference; -import com.gov.zw.dto.License; +import com.gov.zw.domain.License; import com.gov.zw.exception.InvalidIdentityException; import com.gov.zw.exception.InvalidLicenseException; diff --git a/license-service/src/main/java/com/gov/zw/service/LicenseServiceImpl.java b/license-service/src/main/java/com/gov/zw/service/LicenseServiceImpl.java index 8e57da78..1119c4f3 100644 --- a/license-service/src/main/java/com/gov/zw/service/LicenseServiceImpl.java +++ b/license-service/src/main/java/com/gov/zw/service/LicenseServiceImpl.java @@ -3,7 +3,7 @@ import com.gov.zw.client.Identity; import com.gov.zw.client.IdentityClient; import com.gov.zw.client.dto.IdentityReference; -import com.gov.zw.dto.License; +import com.gov.zw.domain.License; import com.gov.zw.exception.InvalidIdentityException; import com.gov.zw.exception.InvalidLicenseException; import com.gov.zw.repository.LicenseRepository; diff --git a/license-service/src/test/java/com/gov/zw/LicenseServiceApplicationTests.java b/license-service/src/test/java/com/gov/zw/LicenseServiceApplicationTests.java index 47d0cb08..ad64335f 100644 --- a/license-service/src/test/java/com/gov/zw/LicenseServiceApplicationTests.java +++ b/license-service/src/test/java/com/gov/zw/LicenseServiceApplicationTests.java @@ -1,11 +1,8 @@ package com.gov.zw; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit.jupiter.SpringExtension; -@ExtendWith(SpringExtension.class) @SpringBootTest class LicenseServiceApplicationTests { diff --git a/license-service/src/test/java/com/gov/zw/client/IdentityClientTest.java b/license-service/src/test/java/com/gov/zw/client/IdentityClientTest.java index 58f5d515..157b87a9 100644 --- a/license-service/src/test/java/com/gov/zw/client/IdentityClientTest.java +++ b/license-service/src/test/java/com/gov/zw/client/IdentityClientTest.java @@ -17,16 +17,17 @@ import java.util.Collections; import java.util.Map; -import static io.restassured.RestAssured.given; +import static com.jayway.restassured.RestAssured.given; import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "IdentityService", port = "9999") @PactFolder("../pacts") -public class IdentityClientTest { +class IdentityClientTest { private static final String IDENTITIES_REFERENCE_PATH = "/identities/reference"; - private static final Map CONTENT_TYPE_JSON_UTF8 = Collections.singletonMap("Content-Type", "application/json;charset=UTF-8"); + private static final Map CONTENT_TYPE_JSON_UTF8 = Collections.singletonMap("Content-Type", APPLICATION_JSON_VALUE); private static final String ID = "1"; private static final String IDENTITY_REF = "MUZAN1234"; private static final String NAME = "Artemas"; diff --git a/license-service/src/test/java/com/gov/zw/controller/LicenseControllerTest.java b/license-service/src/test/java/com/gov/zw/controller/LicenseControllerTest.java index 05ce1f04..4797292d 100644 --- a/license-service/src/test/java/com/gov/zw/controller/LicenseControllerTest.java +++ b/license-service/src/test/java/com/gov/zw/controller/LicenseControllerTest.java @@ -2,17 +2,15 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gov.zw.dto.License; +import com.gov.zw.domain.License; import com.gov.zw.service.LicenseService; import net.minidev.json.JSONObject; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; -import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; @@ -21,7 +19,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -@ExtendWith(SpringExtension.class) @WebMvcTest(LicenseController.class) class LicenseControllerTest { @@ -58,7 +55,7 @@ void shouldAddALicense() throws Exception { JSONObject jsonObject = new JSONObject(licenseObject); mockMvc.perform(MockMvcRequestBuilders.post(LICENSES_URL) - .contentType(MediaType.APPLICATION_JSON_UTF8) + .contentType(MediaType.APPLICATION_JSON) .content(jsonObject.toJSONString())) .andExpect(status().isOk()); } @@ -67,7 +64,7 @@ void shouldAddALicense() throws Exception { @DisplayName("Should throw HttpStatus BAD_REQUEST when trying to add an invalid license") void throwExceptionWhenInvalidLicense() throws Exception { mockMvc.perform(MockMvcRequestBuilders.post(LICENSES_URL) - .contentType(MediaType.APPLICATION_JSON_UTF8) + .contentType(MediaType.APPLICATION_JSON) .content("null")) .andExpect(status().isBadRequest()); } @@ -77,7 +74,7 @@ void throwExceptionWhenInvalidLicense() throws Exception { void shouldThrowBadRequestTryingToGetLicense() throws Exception { mockMvc.perform(MockMvcRequestBuilders.post(LICENSES_URL) - .contentType(MediaType.APPLICATION_JSON_UTF8) + .contentType(MediaType.APPLICATION_JSON) .content("null")) .andExpect(status().isBadRequest()); } @@ -91,7 +88,7 @@ void shouldReturn200WhenAnEmptyLicenseIsPassedToAddLicense() throws Exception { JSONObject jsonObject = new JSONObject(licenseObject); mockMvc.perform(MockMvcRequestBuilders.post(LICENSES_URL) - .contentType(MediaType.APPLICATION_JSON_UTF8) + .contentType(MediaType.APPLICATION_JSON) .content(jsonObject.toJSONString())) .andExpect(status().isOk()); } @@ -114,7 +111,7 @@ void shouldUpdateALicense() throws Exception { JSONObject jsonObject = new JSONObject(licenseObject); mockMvc.perform(MockMvcRequestBuilders.put(LICENSES_URL) - .contentType(MediaType.APPLICATION_JSON_UTF8) + .contentType(MediaType.APPLICATION_JSON) .content(jsonObject.toJSONString())) .andExpect(status().isOk()); } @@ -129,7 +126,7 @@ void shouldReturn200WhenAnEmptyLicenseIsPassedToUpdateLicense() throws Exception mockMvc.perform(MockMvcRequestBuilders.put(LICENSES_URL) - .contentType(MediaType.APPLICATION_JSON_UTF8) + .contentType(MediaType.APPLICATION_JSON) .content(jsonObject.toJSONString())) .andExpect(status().isOk()); } @@ -145,7 +142,7 @@ void shouldDeleteALicense() throws Exception { JSONObject jsonObject = new JSONObject(id); mockMvc.perform(MockMvcRequestBuilders.delete(LICENSES_URL) - .contentType(MediaType.APPLICATION_JSON_UTF8) + .contentType(MediaType.APPLICATION_JSON) .content(jsonObject.toJSONString())) .andExpect(status().isOk()); } @@ -159,7 +156,7 @@ void shouldReturn200WhenAnEmptyLicenseIsPassedToDeleteLicense() throws Exception JSONObject jsonObject = new JSONObject(licenseObject); mockMvc.perform(MockMvcRequestBuilders.delete(LICENSES_URL) - .contentType(MediaType.APPLICATION_JSON_UTF8) + .contentType(MediaType.APPLICATION_JSON) .content(jsonObject.toJSONString())) .andExpect(status().isOk()); } @@ -172,7 +169,7 @@ void shouldReturnLicenseByIdentityRef() throws Exception { JSONObject jsonObject = new JSONObject(idRef); mockMvc.perform(MockMvcRequestBuilders.post("/licenses/ref") - .contentType(MediaType.APPLICATION_JSON_UTF8) + .contentType(MediaType.APPLICATION_JSON) .content(jsonObject.toJSONString())) .andExpect(status().isOk()); } @@ -186,7 +183,7 @@ void shouldReturn200WhenAnEmptyLicenseIsPassedToGetLicenseByIdReference() throws JSONObject jsonObject = new JSONObject(licenseObject); mockMvc.perform(MockMvcRequestBuilders.post("/licenses/ref") - .contentType(MediaType.APPLICATION_JSON_UTF8) + .contentType(MediaType.APPLICATION_JSON) .content(jsonObject.toJSONString())) .andExpect(status().isBadRequest()); } diff --git a/license-service/src/test/java/com/gov/zw/controller/LicenseControllerUnitTest.java b/license-service/src/test/java/com/gov/zw/controller/LicenseControllerUnitTest.java deleted file mode 100644 index c47c214b..00000000 --- a/license-service/src/test/java/com/gov/zw/controller/LicenseControllerUnitTest.java +++ /dev/null @@ -1,132 +0,0 @@ -package com.gov.zw.controller; - -import com.gov.zw.client.IdentityReferenceJson; -import com.gov.zw.client.dto.IdentityReference; -import com.gov.zw.domain.LicenseJson; -import com.gov.zw.dto.License; -import com.gov.zw.service.LicenseService; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -import java.util.List; - -import static java.util.Collections.singletonList; -import static org.assertj.core.api.Java6Assertions.assertThat; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verify; - -@ExtendWith(MockitoExtension.class) -class LicenseControllerUnitTest { - - private static final String ID = "MUZAN1234"; - private static final String IDENTITY_REF = "121"; - private static final String SURNAME = "Muzanenhamo"; - private static final String FIRST_NAMES = "Artemas"; - private static final String DATE_OF_BIRTH = "28/03/1990"; - private static final String COUNTRY = "United Kingdom"; - private static final String DATE_OF_ISSUE = "28/03/2010"; - private static final String EXPIRY_DATE = "28/03/2060"; - private static final String AGENCY = "DVLA"; - private static final String LICENSE_NUMBER = "MUZANK9843ACTK"; - private static final String SIGNATURE_IMAGE = "001.jpg"; - private static final String ADDRESS = "27 Foxhill Street, Guildford, Surrey, GU21 9EE"; - private static final String ID_REF = "some reference"; - private LicenseController licenseController; - @Mock - private LicenseService licenseServiceImpl; - - @BeforeEach - void setUp() { - licenseController = new LicenseController(licenseServiceImpl); - } - - @Test - @DisplayName("Should add license given a valid license") - void addLicense() throws Exception { - License license = new License(ID, IDENTITY_REF, SURNAME, FIRST_NAMES, - DATE_OF_BIRTH, COUNTRY, DATE_OF_ISSUE, - EXPIRY_DATE, AGENCY, LICENSE_NUMBER, SIGNATURE_IMAGE, - ADDRESS); - LicenseJson licenseJson = new LicenseJson(license); - - licenseController.addLicense(licenseJson); - - verify(licenseServiceImpl).addLicense(license); - } - - @Test - @DisplayName("Should get all licenses") - void getAllLicenses() { - List licenseList = singletonList(new License(ID, IDENTITY_REF, SURNAME, FIRST_NAMES, - DATE_OF_BIRTH, COUNTRY, DATE_OF_ISSUE, - EXPIRY_DATE, AGENCY, LICENSE_NUMBER, SIGNATURE_IMAGE, - ADDRESS)); - given(licenseServiceImpl.getAllLicenses()).willReturn(licenseList); - - List licenses = licenseController.getAllLicenses(); - - assertThat(licenses).isNotEmpty(); - LicenseJson licenseJson = licenses.get(0); - assertThat(licenseJson).isNotNull(); - assertThat(licenseJson.getId()).isEqualTo(ID); - assertThat(licenseJson.getIdentityRef()).isEqualTo(IDENTITY_REF); - assertThat(licenseJson.getSurname()).isEqualTo(SURNAME); - assertThat(licenseJson.getFirstNames()).isEqualTo(FIRST_NAMES); - assertThat(licenseJson.getDateOfBirth()).isEqualTo(DATE_OF_BIRTH); - assertThat(licenseJson.getCountry()).isEqualTo(COUNTRY); - assertThat(licenseJson.getDateOfIssue()).isEqualTo(DATE_OF_ISSUE); - assertThat(licenseJson.getExpiryDate()).isEqualTo(EXPIRY_DATE); - assertThat(licenseJson.getAgency()).isEqualTo(AGENCY); - assertThat(licenseJson.getLicenseNumber()).isEqualTo(LICENSE_NUMBER); - assertThat(licenseJson.getSignatureImage()).isEqualTo(SIGNATURE_IMAGE); - assertThat(licenseJson.getAddress()).isEqualTo(ADDRESS); - } - - @Test - @DisplayName("Should return a License given a valid identity reference") - void getLicenseByIdentityRef() throws Exception { - IdentityReference identityReference = new IdentityReference(ID_REF); - IdentityReferenceJson identityRefJson = new IdentityReferenceJson(ID_REF); - License license = new License(ID, IDENTITY_REF, SURNAME, FIRST_NAMES, - DATE_OF_BIRTH, COUNTRY, DATE_OF_ISSUE, - EXPIRY_DATE, AGENCY, LICENSE_NUMBER, SIGNATURE_IMAGE, - ADDRESS); - given(licenseServiceImpl.getLicenseByIdentityRef(identityReference)).willReturn(license); - - LicenseJson licenseJson = licenseController.getLicenseByIdentityRef(identityRefJson); - - assertThat(licenseJson).isNotNull(); - } - - @Test - @DisplayName("Should update an existing license") - void updateLicense() throws Exception { - License license = new License(ID, IDENTITY_REF, SURNAME, FIRST_NAMES, - DATE_OF_BIRTH, COUNTRY, DATE_OF_ISSUE, - EXPIRY_DATE, AGENCY, LICENSE_NUMBER, SIGNATURE_IMAGE, - ADDRESS); - LicenseJson licenseJson = new LicenseJson(license); - - licenseController.updateLicense(licenseJson); - - verify(licenseServiceImpl).updateLicense(license); - } - - @Test - @DisplayName("Should delete an existing license") - void deleteLicense() throws Exception { - License license = new License(ID, IDENTITY_REF, SURNAME, FIRST_NAMES, - DATE_OF_BIRTH, COUNTRY, DATE_OF_ISSUE, - EXPIRY_DATE, AGENCY, LICENSE_NUMBER, SIGNATURE_IMAGE, - ADDRESS); - LicenseJson licenseJson = new LicenseJson(license); - - licenseController.deleteLicense(licenseJson); - - verify(licenseServiceImpl).removeLicense(license); - } -} diff --git a/license-service/src/test/java/com/gov/zw/domain/LicenseJsonTest.java b/license-service/src/test/java/com/gov/zw/domain/LicenseJsonTest.java deleted file mode 100644 index decbf7e1..00000000 --- a/license-service/src/test/java/com/gov/zw/domain/LicenseJsonTest.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.gov.zw.domain; - -import com.gov.zw.dto.License; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -class LicenseJsonTest { - private static final String ID = "MUZAN1234"; - private static final String IDENTITY_REF = "121"; - private static final String SURNAME = "Muzanenhamo"; - private static final String FIRST_NAMES = "Artemas"; - private static final String DATE_OF_BIRTH = "28/03/1990"; - private static final String COUNTRY = "United Kingdom"; - private static final String DATE_OF_ISSUE = "28/03/2010"; - private static final String EXPIRY_DATE = "28/03/2060"; - private static final String AGENCY = "DVLA"; - private static final String LICENSE_NUMBER = "MUZANK9843ACTK"; - private static final String SIGNATURE_IMAGE = "001.jpg"; - private static final String ADDRESS = "27 Foxhill Street, Guildford, Surrey, GU21 9EE"; - private LicenseJson licenseJson; - - @BeforeEach - void init() { - licenseJson = new LicenseJson(); - } - - @Test - @DisplayName("Both LicenseJson objects should be equal") - void equalityCheck() { - LicenseJson expectedLicenseJson = new LicenseJson(new License(ID, IDENTITY_REF, SURNAME, FIRST_NAMES, - DATE_OF_BIRTH, COUNTRY, DATE_OF_ISSUE, - EXPIRY_DATE, AGENCY, LICENSE_NUMBER, SIGNATURE_IMAGE, - ADDRESS)); - - licenseJson = new LicenseJson(new License(ID, IDENTITY_REF, SURNAME, FIRST_NAMES, - DATE_OF_BIRTH, COUNTRY, DATE_OF_ISSUE, - EXPIRY_DATE, AGENCY, LICENSE_NUMBER, SIGNATURE_IMAGE, - ADDRESS)); - - assertThat(licenseJson).isEqualTo(expectedLicenseJson) - .hasToString(expectedLicenseJson.toString()) - .hasSameHashCodeAs(expectedLicenseJson.hashCode()); - } -} diff --git a/license-service/src/test/java/com/gov/zw/dto/LicenseTest.java b/license-service/src/test/java/com/gov/zw/dto/LicenseTest.java deleted file mode 100644 index 88588d66..00000000 --- a/license-service/src/test/java/com/gov/zw/dto/LicenseTest.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.gov.zw.dto; - -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; - -class LicenseTest { - - private License license; - private License license2; - - @BeforeEach - void init() { - license = new License( - "1", "1234AMUZ1", "Muzanenhamo", "Artemas Takudzwa", - "28/03/1990", "ZIM", "20/11/2017", "19/11/2027", "ZDVLA", - "MUZANEN123456ABCDEF", "signature.jpg", "768 Sunningdale 3, Harare, Zimbabwe"); - - license2 = new License( - "1", "1234AMUZ1", "Muzanenhamo", "Artemas Takudzwa", - "28/03/1990", "ZIM", "20/11/2017", "19/11/2027", "ZDVLA", - "MUZANEN123456ABCDEF", "signature.jpg", "768 Sunningdale 3, Harare, Zimbabwe"); - } - - @Test - void creation() { - - Assertions.assertThat(license.getId()).isEqualTo("1"); - Assertions.assertThat(license.getIdentityRef()).isEqualTo("1234AMUZ1"); - Assertions.assertThat(license.getSurname()).isEqualTo("Muzanenhamo"); - Assertions.assertThat(license.getFirstNames()).isEqualTo("Artemas Takudzwa"); - Assertions.assertThat(license.getDateOfBirth()).isEqualTo("28/03/1990"); - Assertions.assertThat(license.getCountry()).isEqualTo("ZIM"); - Assertions.assertThat(license.getDateOfIssue()).isEqualTo("20/11/2017"); - Assertions.assertThat(license.getExpiryDate()).isEqualTo("19/11/2027"); - Assertions.assertThat(license.getAgency()).isEqualTo("ZDVLA"); - Assertions.assertThat(license.getLicenseNumber()).isEqualTo("MUZANEN123456ABCDEF"); - Assertions.assertThat(license.getSignatureImage()).isEqualTo("signature.jpg"); - Assertions.assertThat(license.getAddress()).isEqualTo("768 Sunningdale 3, Harare, Zimbabwe"); - - Assertions.assertThat(license).isEqualTo(license2); - } - - - @Test - void licenceIsEqual() { - assertEquals(true, license.equals(license2)); - } - - @Test - void licenseNotEqual() { - License license3 = new License(); - assertNotEquals(true, license.equals(license3)); - } - - @Test - void hashCodesNotEqual(){ - assertNotEquals(false,license.hashCode() == license2.hashCode()); - } - - @Test - void hashCodesEqual(){ - license2 = license; - assertEquals(true, license.hashCode() == license2.hashCode()); - } - - @Test - void emptyToString(){ - License license = new License(); - License license1 = new License(); - assertEquals(license1.toString(), license.toString()); - } - -} diff --git a/license-service/src/test/java/com/gov/zw/mapper/LicenseMapperTest.java b/license-service/src/test/java/com/gov/zw/mapper/LicenseMapperTest.java index 26d18d7d..0afb3581 100644 --- a/license-service/src/test/java/com/gov/zw/mapper/LicenseMapperTest.java +++ b/license-service/src/test/java/com/gov/zw/mapper/LicenseMapperTest.java @@ -1,7 +1,7 @@ package com.gov.zw.mapper; -import com.gov.zw.dto.License; -import com.gov.zw.domain.LicenseJson; +import com.gov.zw.domain.License; +import com.gov.zw.json.LicenseJson; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -33,7 +33,7 @@ void mapLicenseJsonToDTO() { DATE_OF_BIRTH, COUNTRY, DATE_OF_ISSUE, EXPIRY_DATE, AGENCY, LICENSE_NUMBER, SIGNATURE_IMAGE, ADDRESS); - LicenseJson licenseJson = new LicenseJson(expectedLicense); + LicenseJson licenseJson = toLicenseJson(expectedLicense); License license = toLicenseDTO(licenseJson); diff --git a/license-service/src/test/java/com/gov/zw/repository/LicenseRepositoryTest.java b/license-service/src/test/java/com/gov/zw/repository/LicenseRepositoryTest.java index a903a997..e468724e 100644 --- a/license-service/src/test/java/com/gov/zw/repository/LicenseRepositoryTest.java +++ b/license-service/src/test/java/com/gov/zw/repository/LicenseRepositoryTest.java @@ -1,20 +1,17 @@ package com.gov.zw.repository; -import com.gov.zw.dto.License; +import com.gov.zw.domain.License; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest; -import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.Arrays; import java.util.List; @DataMongoTest -@ExtendWith(SpringExtension.class) class LicenseRepositoryTest { @Autowired diff --git a/license-service/src/test/java/com/gov/zw/service/LicenseServiceTest.java b/license-service/src/test/java/com/gov/zw/service/LicenseServiceTest.java index 76fa324d..2393ad29 100644 --- a/license-service/src/test/java/com/gov/zw/service/LicenseServiceTest.java +++ b/license-service/src/test/java/com/gov/zw/service/LicenseServiceTest.java @@ -3,17 +3,17 @@ import com.gov.zw.client.Identity; import com.gov.zw.client.IdentityClient; import com.gov.zw.client.dto.IdentityReference; -import com.gov.zw.dto.License; +import com.gov.zw.domain.License; import com.gov.zw.exception.InvalidIdentityException; import com.gov.zw.exception.InvalidLicenseException; import com.gov.zw.repository.LicenseRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.springframework.test.context.junit4.SpringRunner; +import org.mockito.junit.jupiter.MockitoExtension; import java.util.Collections; import java.util.List; @@ -24,7 +24,7 @@ import static org.mockito.Mockito.*; import static org.mockito.MockitoAnnotations.initMocks; -@RunWith(SpringRunner.class) +@ExtendWith(MockitoExtension.class) class LicenseServiceTest { private static final String ID_REF = "1"; @@ -80,7 +80,7 @@ void returnIdentityByReference() throws Exception { @Test @DisplayName("Should throw an InvalidIdentityException when an ID ref that is not an INT is passed") - void throwExceptionWhenIdRefIsNotAnInt() throws Exception { + void throwExceptionWhenIdRefIsNotAnInt() { License license = new License(); license.setId(ID); license.setIdentityRef(IDENTITY_REF); diff --git a/pacts/license-service-identity-service.json b/pacts/license-service-identity-service.json index 74b0a3f2..cc8c7baa 100644 --- a/pacts/license-service-identity-service.json +++ b/pacts/license-service-identity-service.json @@ -117,4 +117,4 @@ "version": "3.6.11" } } -} +} \ No newline at end of file