Skip to content

Commit

Permalink
upgrade license-service to Spring Boot 2.2.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Artemas-Muzanenhamo committed Mar 24, 2024
1 parent 7dd89e2 commit fae271d
Show file tree
Hide file tree
Showing 27 changed files with 217 additions and 482 deletions.
67 changes: 34 additions & 33 deletions license-service/build.gradle
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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}"
}
Expand Down
22 changes: 2 additions & 20 deletions license-service/gradle.properties
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion license-service/src/main/java/com/gov/zw/DBSeeder.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.gov.zw.client;

import lombok.Getter;

import java.util.Objects;

@Getter
public class IdentityReferenceJson {
public String idRef;

Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package com.gov.zw.client.dto;

import lombok.Getter;

import java.util.Objects;

@Getter
public class IdentityReference {
private final String idRef;

public IdentityReference(String idRef) {
this.idRef = idRef;
}

public String getIdRef() {
return idRef;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.gov.zw.client.exception;

public class IdentityReferenceJsonNotValidException extends RuntimeException {
public IdentityReferenceJsonNotValidException() {
}

public IdentityReferenceJsonNotValidException(String message) {
super(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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")
Expand All @@ -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<LicenseJson> getAllLicenses() {
List<License> 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);
Expand Down
130 changes: 130 additions & 0 deletions license-service/src/main/java/com/gov/zw/domain/License.java
Original file line number Diff line number Diff line change
@@ -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 + '\'' +
'}';
}
}

0 comments on commit fae271d

Please sign in to comment.