Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: test adjust #420

Merged
merged 11 commits into from
Oct 28, 2024
2 changes: 1 addition & 1 deletion .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
java-distribution: temurin
java-version: 21
sonar_args: >
-Dsonar.exclusions=**/config/**,**/converter/**,**/dto/**,**/entity/**,**/exception/**,**/job/**,**/response/**,**/*$*Builder*,**/RestExceptionEndpoint.*,**/ResultsApplication.*
-Dsonar.exclusions=**/configuration/**,**/dto/**,**/entity/**,**/exception/**,**/job/**,**/*$*Builder*,**/ResultsApplication.*,**/*Constants.*,
-Dsonar.coverage.jacoco.xmlReportPaths=target/coverage-reports/merged-test-report/jacoco.xml
-Dsonar.organization=bcgov-sonarcloud
-Dsonar.project.monorepo.enabled=true
Expand Down
39 changes: 19 additions & 20 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<skip.unit.tests>true</skip.unit.tests>
<jacoco.skip>true</jacoco.skip>
<checkstyle.skip>true</checkstyle.skip>
<checkstyle.failsOnError>true</checkstyle.failsOnError>
<checkstyle.failsOnError>false</checkstyle.failsOnError>
<checkstyle.includeTestSourceDirectory>true</checkstyle.includeTestSourceDirectory>
<jacoco.output.data>${project.build.directory}/coverage-reports</jacoco.output.data>
<timestamp>${maven.build.timestamp}</timestamp>
Expand Down Expand Up @@ -120,11 +120,17 @@
</profiles>

<dependencies>
<!-- Spring Boot and tools -->
<!-- Spring Boot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>

<!-- Tools -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand All @@ -136,6 +142,11 @@
<artifactId>prettytime</artifactId>
<version>5.0.9.Final</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.17.0</version>
</dependency>

<!-- DevOps -->
<dependency>
Expand All @@ -151,6 +162,7 @@
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc11</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
Expand All @@ -168,6 +180,7 @@
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
Expand All @@ -176,7 +189,7 @@
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>oracle-xe</artifactId>
<artifactId>oracle-free</artifactId>
<scope>test</scope>
</dependency>

Expand All @@ -186,14 +199,10 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
Expand All @@ -212,13 +221,6 @@
<scope>test</scope>
</dependency>

<!-- Documentation -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.6.0</version>
</dependency>

<!-- Authentication and Security -->
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -332,17 +334,14 @@
<configuration>
<skip>${jacoco.skip}</skip>
<excludes>
<exclude>**/config/**</exclude>
<exclude>**/converter/**</exclude>
<exclude>**/configuration/**</exclude>
<exclude>**/dto/**</exclude>
<exclude>**/entity/**</exclude>
<exclude>**/exception/**</exclude>
<exclude>**/job/**</exclude>
<exclude>**/response/**</exclude>
<exclude>**/*$*Builder*</exclude>
<exclude>**/RestExceptionEndpoint.*</exclude>
<exclude>**/Controller.*</exclude>
<exclude>**/ResultsApplication.*</exclude>
<exclude>**/*Constants.*</exclude>
</excludes>
</configuration>
<executions>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,22 @@

import ca.bc.gov.restapi.results.common.enums.ForestClientStatusEnum;
import ca.bc.gov.restapi.results.common.enums.ForestClientTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.With;

/**
* This record represents a Forest Client object.
*/
@Schema(description = "One of the many agencies that work with the ministry.")
@Builder
@With
public record ForestClientDto(
@Schema(description = "An eight-digit number that identifies the client.", example = "00149081")
String clientNumber,
@Schema(
description =
"The client last name if it's an individual or the company name if it's a company.",
example = "WESTERN FOREST PRODUCTS INC.")
String clientName,
@Schema(
description = "The first name of the individual, or null if it's a company.",
example = "Maria")
String legalFirstName,
@Schema(
description = "The middle name of the individual, or null if it's a company",
example = "Bricks")
String legalMiddleName,
@Schema(
description =
"A code indicating the status of ministry client. Examples include but are not"
+ " limited to: Active, Deactivated, Deceased...",
example = "ACT")
ForestClientStatusEnum clientStatusCode,
@Schema(
description =
"A code indicating a type of ministry client. Examples include but are not limited"
+ " to: Corporation, Individual, Association, First Nation..",
example = "C")
ForestClientTypeEnum clientTypeCode,
@Schema(
description = "An acronym for this client; works as an alternative identifier.",
example = "WFP")
String acronym) {
String acronym
) {

}
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
package ca.bc.gov.restapi.results.common.endpoint;

import ca.bc.gov.restapi.results.common.service.RestService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
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.tags.Tag;
import ca.bc.gov.restapi.results.common.service.OpenMapsService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/** This class holds resources for calling WFS. */
/**
* This class holds resources for calling WFS.
*/
@RestController
@RequestMapping("/api/feature-service")
@AllArgsConstructor
@Tag(
name = "Feature Service to call WFS (Common)",
description = "Endpoints for handle WFS (Web Feature Service) within BC Geo Warehouse")
public class FeatureServiceEndpoint {

private final RestService restService;
private final OpenMapsService openMapsService;

/**
* Fetch Opening data from WFS.
Expand All @@ -32,29 +24,9 @@ public class FeatureServiceEndpoint {
* @return JSON object with response from WFS request
*/
@GetMapping("/polygon-and-props/{openingId}")
@Operation(
summary = "Fetch Opening data from WFS",
description =
"Fetch Opening data (polygon raster data and properties) from WFS. These are the props "
+ "being fetched: OPENING_ID, GEOMETRY, REGION_NAME, REGION_CODE, DISTRICT_NAME, "
+ "DISTRICT_CODE, CLIENT_NAME, CLIENT_NUMBER, and OPENING_WHEN_CREATED",
responses = {
@ApiResponse(
responseCode = "200",
description = "An object with the response from WFS request."),
@ApiResponse(
responseCode = "401",
description = "Access token is missing or invalid",
content = @Content(schema = @Schema(implementation = Void.class)))
})
public Object getOpeningPolygonAndProperties(
@Parameter(
name = "openingId",
in = ParameterIn.PATH,
description = "The opening Id.",
required = true)
@PathVariable
String openingId) {
return restService.getOpeningPolygonAndProperties(openingId);
@PathVariable
String openingId) {
return openMapsService.getOpeningPolygonAndProperties(openingId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,18 @@
import ca.bc.gov.restapi.results.common.dto.ForestClientDto;
import ca.bc.gov.restapi.results.common.exception.ForestClientNotFoundException;
import ca.bc.gov.restapi.results.common.service.ForestClientService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
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.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/** This class holds resources for the Forest Client API interaction. */
/**
* This class holds resources for the Forest Client API interaction.
*/
@RestController
@RequestMapping("/api/forest-clients")
@AllArgsConstructor
@Tag(
name = "Forest Client (Common)",
description = "Endpoints for fetching client information from Forest Client API")
public class ForestClientEndpoint {

private final ForestClientService forestClientService;
Expand All @@ -35,30 +27,7 @@ public class ForestClientEndpoint {
* @throws ForestClientNotFoundException when client not found
*/
@GetMapping("/{clientNumber}")
@Operation(
summary = "Fetch a forest client given its number.",
description =
"Fetch a forest client directly from the ForestClient API given the client number.",
responses = {
@ApiResponse(
responseCode = "200",
description = "An object with all client properties provided by the ForestClient API."),
@ApiResponse(
responseCode = "400",
description = "Something wrong with the client number, make sure you're sending it."),
@ApiResponse(
responseCode = "401",
description = "Access token is missing or invalid",
content = @Content(schema = @Schema(implementation = Void.class)))
})
public ForestClientDto getForestClient(
@Parameter(
name = "clientNumber",
in = ParameterIn.PATH,
description = "The client number to be fetched.",
required = true)
@PathVariable
String clientNumber) {
public ForestClientDto getForestClient(@PathVariable String clientNumber) {
return forestClientService
.getClientByNumber(clientNumber)
.orElseThrow(ForestClientNotFoundException::new);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package ca.bc.gov.restapi.results.common.endpoint;

import ca.bc.gov.restapi.results.common.dto.WmsLayersWhitelistUserDto;
import io.swagger.v3.oas.annotations.Hidden;
import java.util.List;
import java.util.stream.Stream;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/** This class holds resources for getting secrets from the backend. */
/**
* This class holds resources for getting secrets from the backend.
*/
@RestController
@RequestMapping("/api/secrets")
@Hidden
public class SecretsServiceEndpoint {

@Value("${nr.results.config.wms-layers.whitelist}")
Expand Down
Loading
Loading