Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/automation-test' into fe…
Browse files Browse the repository at this point in the history
…ature/automation-test
  • Loading branch information
maxchernohorntt committed Aug 15, 2024
2 parents fc3c818 + 7229856 commit b636267
Show file tree
Hide file tree
Showing 17 changed files with 87 additions and 137 deletions.
8 changes: 4 additions & 4 deletions cccm-automation-test-ui/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ RUN wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor
apt-get update && \
apt-get install -y microsoft-edge-stable

ARG PASSWORD_APP=$PASSWORD_APP
ARG USERNAME_APP=$USERNAME_APP
ENV USERNAME_APP=${USERNAME_APP}
ENV PASSWORD_APP=${PASSWORD_APP}
#ARG PASSWORD_APP=$PASSWORD_APP
#ARG USERNAME_APP=$USERNAME_APP
#ENV USERNAME_APP=${USERNAME_APP}
#ENV PASSWORD_APP=${PASSWORD_APP}

# copy local jar
#COPY ./target/cccm-automation-test-jag-0.0.1-SNAPSHOT-test-jar-with-dependencies.jar .
Expand Down
6 changes: 6 additions & 0 deletions cccm-automation-test-ui/cccm-automation-test-ui.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="SonarLintModuleSettings">
<option name="uniqueId" value="05fa9d5c-6bf8-403d-ae79-b54a998f6308" />
</component>
</module>
9 changes: 8 additions & 1 deletion cccm-automation-test-ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

<name>CCCM-testing</name>


<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<io.github.bonigarcia.version>5.6.3</io.github.bonigarcia.version>
<org.seleniumhq.selenium.version>4.11.0</org.seleniumhq.selenium.version>
<org.seleniumhq.selenium.version>4.13.0</org.seleniumhq.selenium.version>
<com.microsoft.sqlserver.version>6.4.0.jre8</com.microsoft.sqlserver.version>
<junit.version>4.13.1</junit.version>
<org.apache.pdfbox.version>2.0.26</org.apache.pdfbox.version>
Expand All @@ -22,6 +23,7 @@
</properties>

<dependencies>

<!-- Selenium Drivers -->
<dependency>
<groupId>io.github.bonigarcia</groupId>
Expand Down Expand Up @@ -101,6 +103,11 @@
<artifactId>jackson-databind</artifactId>
<version>2.13.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

import java.time.Duration;


public class CommonMethods {


private static int defaultSleepBeforeAction = 1;
private static String appUSERNAME = System.getenv("USERNAME_APP");
private static String appPASSWORD = System.getenv("PASSWORD_APP");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,46 +28,4 @@ public static void openLogin() throws Exception {
}
}

// Construct jdbcUrl for Environment
public static String getJdbcUrl() {
String jdbcUrl = "";
if (Config.ENVIROMENT.equals(Constants.DEV)) {
jdbcUrl = "jdbc:oracle:thin:@devdb.bcgov:1521:devj";
} else if (Config.ENVIROMENT.equals(Constants.TST)) {
jdbcUrl = "jdbc:oracle:thin:@testdb.bcgov:1521:tstj";
}

String dbName = "";

if (Config.ENVIROMENT.equals(Constants.DEV)) {
dbName = "DatabaseName=";
} else if (Config.ENVIROMENT.equals(Constants.TST)) {
dbName = "DatabaseName=";
}

return jdbcUrl;
}

// Construct userName for Environment
public static String getJdbcUserName() {
String userName = "";
if (Config.ENVIROMENT.equals(Constants.DEV)) {
userName = "jdbcUserName.DEV";
} else if (Config.ENVIROMENT.equals(Constants.TST)) {
userName = "jdbcUserName.TST";
}
return userName;
}

// Construct password for Environment
public static String getJdbcPassword() {
String password = "";
if (Config.ENVIROMENT.equals(Constants.DEV)) {
password = "jdbcPassword.DEV";
} else if (Config.ENVIROMENT.equals(Constants.TST)) {
password = "jdbcPassword.TST";
}
return password;
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
USERNAME_APP=${USERNAME_APP}
PASSWORD_APP=${PASSWORD_APP}
PASSWORD_APP=${PASSWORD_APP}
BASE_URL=${BASE_URL}
DB_CONNECTION=${DB_CONNECTION}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ public interface CodeTableMapper {
@Mapping(target = "value", source = "value")
Code toCode(CodeTable codeTable);


}
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package ca.bc.gov.open.jag.api.mapper;

import ca.bc.gov.open.jag.api.model.data.CodeTable;
import ca.bc.gov.open.jag.api.model.data.Location;
import ca.bc.gov.open.jag.cccm.api.openapi.model.Code;
import ca.bc.gov.open.jag.cccm.api.openapi.model.CodeList;
import ca.bc.gov.open.jag.cccm.api.openapi.model.LocationCode;
import ca.bc.gov.open.jag.cccm.api.openapi.model.LocationCodeList;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

Expand All @@ -18,4 +21,12 @@ public interface LocationMapper {
@Mapping(target = "value", source = "dsc")
Code toCode(Location location);

@Mapping(target = "items", source = "locations")
LocationCodeList toLocationCodeResult(String dummyValue, List<Location> locations);

@Mapping(target = "key", source = "id")
@Mapping(target = "value", source = "dsc")
@Mapping(target = "locationTypeCode", source = "lotyCd")
LocationCode toLocationCode(Location location);

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

public interface UserDataService {

Code getDefaultLocation(String user);
LocationCode getDefaultLocation(String user);

CodeList getLocations(String user);
LocationCodeList getLocations(String user);

String getOracleId(String user);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public UserDataServiceImpl(@RestClient ObridgeClientService obridgeClientService
}

@Override
public Code getDefaultLocation(String user) {
public LocationCode getDefaultLocation(String user) {

logger.debug("Default Location {}", user);

Expand All @@ -51,7 +51,7 @@ public Code getDefaultLocation(String user) {
}

@Override
public CodeList getLocations(String user) {
public LocationCodeList getLocations(String user) {

logger.debug("Default Locations {}", user);

Expand All @@ -61,7 +61,7 @@ public CodeList getLocations(String user) {
logger.info("Getting Locations Code For Default Locations");
List<Location> locations = obridgeClientService.getLocations(oracleId);

return locationMapper.toCodeResult("", locations);
return locationMapper.toLocationCodeResult("", locations);
}

@Override
Expand Down Expand Up @@ -145,13 +145,14 @@ public List<PO> getPOList(String user, BigDecimal location) {

}

private Code getCode(String oracleId) {
private LocationCode getCode(String oracleId) {

Location location = obridgeClientService.getLocation(oracleId);

Code code = new Code();
LocationCode code = new LocationCode();
code.setKey(location.getId().toPlainString());
code.setValue(location.getDsc());
code.setLocationTypeCode(location.getlotyCd());

return code;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import ca.bc.gov.open.jag.api.service.UserDataServiceImpl;
import ca.bc.gov.open.jag.cccm.api.openapi.UserApi;
import ca.bc.gov.open.jag.cccm.api.openapi.model.Code;
import ca.bc.gov.open.jag.cccm.api.openapi.model.CodeList;
import ca.bc.gov.open.jag.cccm.api.openapi.model.LogonResult;
import ca.bc.gov.open.jag.cccm.api.openapi.model.PO;
import ca.bc.gov.open.jag.cccm.api.openapi.model.*;
import org.eclipse.microprofile.jwt.Claim;
import org.eclipse.microprofile.jwt.Claims;
import org.slf4j.Logger;
Expand Down Expand Up @@ -41,7 +38,7 @@ public LogonResult getLogon(@NotNull String locationType) {

@Override
@RolesAllowed("data-view")
public Code getUserDefaultLocation() {
public LocationCode getUserDefaultLocation() {

logger.info("Default Location Request");

Expand All @@ -61,7 +58,7 @@ public String getUserId() {

@Override
@RolesAllowed("data-view")
public CodeList getUserLocations() {
public LocationCodeList getUserLocations() {

logger.info("User Locations Request");

Expand Down
20 changes: 17 additions & 3 deletions cccm-backend/cccm-api/src/main/resources/cccm-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1980,7 +1980,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Code'
$ref: '#/components/schemas/LocationCode'
description: get users default location
summary: get users default location
tags:
Expand All @@ -1996,7 +1996,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/CodeList'
$ref: '#/components/schemas/LocationCodeList'
description: get users locations
summary: get users locations
tags:
Expand Down Expand Up @@ -2651,6 +2651,20 @@ components:
type: number
dueSeven:
type: number
LocationCode:
allOf:
- $ref: '#/components/schemas/Code'
- type: object
properties:
locationTypeCode:
type: string
LocationCodeList:
properties:
items:
description: Code Type Results
items:
$ref: '#/components/schemas/LocationCode'
type: array
Code:
type: object
properties:
Expand Down Expand Up @@ -3069,7 +3083,7 @@ components:
type: object
properties:
defaultLocation:
$ref: '#/components/schemas/Code'
$ref: '#/components/schemas/LocationCode'
locations:
$ref: '#/components/schemas/CodeList'
User:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ca.bc.gov.open.jag.api.service.ObridgeClientService;
import ca.bc.gov.open.jag.api.service.UserDataService;
import ca.bc.gov.open.jag.cccm.api.openapi.model.Code;
import ca.bc.gov.open.jag.cccm.api.openapi.model.LocationCode;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.InjectMock;
import org.eclipse.microprofile.rest.client.inject.RestClient;
Expand Down Expand Up @@ -37,13 +38,15 @@ public void testGetFormTypes() {
locationMock.setId(TEST_ID);
locationMock.setAlternateCd(TEST_CD);
locationMock.setDsc(TEST_VALUE);
locationMock.setlotyCd(TEST_VALUE);
Mockito.when(obridgeClientService.getOracleId(Mockito.any())).thenReturn(TEST_ID.toPlainString());
Mockito.when(obridgeClientService.getLocation(Mockito.any())).thenReturn(locationMock);

Code result = sut.getDefaultLocation("test@idir");
LocationCode result = sut.getDefaultLocation("test@idir");

Assertions.assertEquals(TEST_ID.toPlainString(), result.getKey());
Assertions.assertEquals(TEST_VALUE, result.getValue());
Assertions.assertEquals(TEST_VALUE, result.getLocationTypeCode());

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ca.bc.gov.open.jag.api.service.ObridgeClientService;
import ca.bc.gov.open.jag.api.service.UserDataService;
import ca.bc.gov.open.jag.cccm.api.openapi.model.CodeList;
import ca.bc.gov.open.jag.cccm.api.openapi.model.LocationCodeList;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.InjectMock;
import org.eclipse.microprofile.rest.client.inject.RestClient;
Expand Down Expand Up @@ -47,7 +48,7 @@ public void testGetLocations() {
Mockito.when(obridgeClientService.getOracleId(Mockito.any())).thenReturn(TEST_ID.toPlainString());
Mockito.when(obridgeClientService.getLocations(Mockito.any())).thenReturn(locationListMock);

CodeList result = sut.getLocations("test@idir");
LocationCodeList result = sut.getLocations("test@idir");

Assertions.assertEquals(1, result.getItems().size());
Assertions.assertEquals(TEST_ID.toPlainString(), result.getItems().get(0).getKey());
Expand Down
Loading

0 comments on commit b636267

Please sign in to comment.