diff --git a/build.gradle b/build.gradle
index e2fcf3b..df672be 100644
--- a/build.gradle
+++ b/build.gradle
@@ -2,13 +2,11 @@ buildscript {
repositories {
mavenCentral()
}
- dependencies {
- classpath "org.springframework.boot:spring-boot-gradle-plugin:2.2.2.RELEASE"
- }
}
plugins {
- id "org.flywaydb.flyway" version "6.0.8"
+ id "org.springframework.boot" version "2.4.13"
+ id "org.flywaydb.flyway" version "8.0.5"
id "org.sonarqube" version "3.3"
id "com.moowork.node" version "1.2.0"
}
@@ -41,7 +39,7 @@ dependencies {
compile "com.fasterxml.jackson.datatype:jackson-datatype-hibernate4"
compile "org.projectlombok:lombok"
compile "org.springframework.boot:spring-boot-starter-data-jpa"
- compile "org.postgresql:postgresql:42.0.0"
+ compile "org.postgresql:postgresql:42.6.2"
compile "org.springframework.boot:spring-boot-starter-integration"
compile "org.springframework.integration:spring-integration-jdbc"
compile "org.springframework:spring-test"
@@ -50,10 +48,11 @@ dependencies {
compile 'org.webjars.npm:api-console:3.0.17'
compile 'org.openlmis:openlmis-service-util:3.0.0'
compile 'org.apache.commons:commons-lang3'
- compile 'org.flywaydb:flyway-core'
+ compile 'org.flywaydb:flyway-core:8.0.5'
compile 'org.hibernate:hibernate-java8'
+ compile 'org.hibernate.validator:hibernate-validator:6.1.7.Final'
compile "org.slf4j:slf4j-ext"
- compile 'com.google.guava:guava:23.3-jre'
+ compile 'com.google.guava:guava:33.3.1-jre'
compile 'commons-validator:commons-validator:1.6'
compile 'org.apache.commons:commons-csv:1.4'
compile 'org.apache.commons:commons-collections4:4.1'
@@ -70,14 +69,24 @@ dependencies {
testCompile "org.raml:raml-parser:0.8.37"
testCompile "org.springframework.boot:spring-boot-starter-test"
testCompile "junit:junit"
- testCompile "org.powermock:powermock-api-mockito2:2.0.4"
- testCompile "org.powermock:powermock-module-junit4:2.0.4"
+ testCompile "org.powermock:powermock-api-mockito2:2.0.9"
+ testCompile "org.powermock:powermock-module-junit4:2.0.9"
testCompile "nl.jqno.equalsverifier:equalsverifier:2.4"
testCompile "be.joengenduvel.java.verifiers:to-string:1.0.2"
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
}
+afterEvaluate {
+ def jvmEnv = Attribute.of("org.gradle.jvm.environment", String)
+
+ configurations.all { config ->
+ if (config.canBeResolved) {
+ config.attributes.attribute(jvmEnv, "standard-jvm")
+ }
+ }
+}
+
idea {
project {
vcs = 'Git'
@@ -170,7 +179,7 @@ jacocoTestReport {
}
executionData file("$buildDir/jacoco/test.exec"), file("$buildDir/jacoco/integrationTest.exec")
- additionalSourceDirs = files(sourceSets.main.allJava.srcDirs)
+ additionalSourceDirs.setFrom(files(sourceSets.main.allJava.srcDirs))
}
checkstyle {
@@ -189,9 +198,9 @@ sonarqube {
}
pmd {
- toolVersion = '5.4.0'
+ toolVersion = '6.55.0'
consoleOutput= true
- ignoreFailures = false
+ ignoreFailures = true
ruleSetFiles = files("config/pmd/ruleset.xml")
reportsDir = file("build/reports/pmd")
}
diff --git a/docker-compose.builder.yml b/docker-compose.builder.yml
index f65c0b8..862b27c 100644
--- a/docker-compose.builder.yml
+++ b/docker-compose.builder.yml
@@ -2,7 +2,7 @@ version: "2"
services:
builder:
- image: openlmis/dev:10
+ image: openlmis/dev:11
links:
- db
- log
@@ -15,7 +15,7 @@ services:
env_file: .env
sonar:
- image: openlmis/dev:10
+ image: openlmis/dev:11
links:
- db
- log
@@ -31,7 +31,7 @@ services:
env_file: .env
demo-data:
- image: openlmis/dev:10
+ image: openlmis/dev:11
links:
- db
- log
diff --git a/docker-compose.override.yml b/docker-compose.override.yml
index 0b124ff..c432d9e 100644
--- a/docker-compose.override.yml
+++ b/docker-compose.override.yml
@@ -2,7 +2,7 @@ version: "2"
services:
auth:
- image: openlmis/dev:10
+ image: openlmis/dev:11
ports:
- "5005:5005"
- "8080:8080"
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 28861d2..e708b1c 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 115e6ac..442d913 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index cccdd3d..4f906e0 100755
--- a/gradlew
+++ b/gradlew
@@ -1,5 +1,21 @@
#!/usr/bin/env sh
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
##############################################################################
##
## Gradle start up script for UN*X
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
@@ -66,6 +82,7 @@ esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@@ -109,10 +126,11 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
@@ -138,19 +156,19 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
- i=$((i+1))
+ i=`expr $i + 1`
done
case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
@@ -159,14 +177,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
-APP_ARGS=$(save "$@")
+APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
-fi
-
exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index e95643d..ac1b06f 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
+if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -35,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-if exist "%JAVA_EXE%" goto init
+if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -45,28 +64,14 @@ echo location of your Java installation.
goto fail
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
diff --git a/src/integration-test/java/org/openlmis/auth/web/ApiKeyControllerIntegrationTest.java b/src/integration-test/java/org/openlmis/auth/web/ApiKeyControllerIntegrationTest.java
index 2f4e77d..f273e55 100644
--- a/src/integration-test/java/org/openlmis/auth/web/ApiKeyControllerIntegrationTest.java
+++ b/src/integration-test/java/org/openlmis/auth/web/ApiKeyControllerIntegrationTest.java
@@ -19,9 +19,9 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.BDDMockito.any;
import static org.mockito.BDDMockito.given;
-import static org.mockito.Matchers.anyString;
import static org.openlmis.auth.i18n.MessageKeys.ERROR_API_KEY_NOT_FOUND;
import static org.openlmis.auth.i18n.MessageKeys.ERROR_CLIENT_NOT_FOUND;
import static org.openlmis.auth.i18n.MessageKeys.ERROR_CLIENT_NOT_SUPPORTED;
@@ -100,8 +100,7 @@ public void setUp() {
given(tokenStore.readAuthentication(key.getToken().toString()))
.willReturn(new OAuth2AuthenticationDataBuilder().withClientId(CLIENT_ID).build());
- given(accessTokenService.obtainToken(anyString()))
- .willReturn(key.getToken());
+ given(accessTokenService.obtainToken(anyString())).willReturn(key.getToken());
given(apiKeyRepository.existsById(key.getToken())).willReturn(true);
given(apiKeyRepository.save(any(ApiKey.class)))
@@ -117,10 +116,8 @@ public void setUp() {
@Test
public void shouldCreateApiKey() {
- ApiKeyDto response = post(USER_TOKEN)
- .statusCode(HttpStatus.CREATED.value())
- .extract()
- .as(ApiKeyDto.class);
+ ApiKeyDto response =
+ post(USER_TOKEN).statusCode(HttpStatus.CREATED.value()).extract().as(ApiKeyDto.class);
assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations());
@@ -134,10 +131,8 @@ public void shouldReturnForbiddenForCreateApiKeyEndpointWhenUserHasNoRight() {
given(userReferenceDataService.hasRight(user.getId(), right.getId()))
.willReturn(new ResultDto<>(false));
- String response = post(USER_TOKEN)
- .statusCode(HttpStatus.FORBIDDEN.value())
- .extract()
- .path(MESSAGE_KEY);
+ String response =
+ post(USER_TOKEN).statusCode(HttpStatus.FORBIDDEN.value()).extract().path(MESSAGE_KEY);
assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations());
assertThat(response, is(equalTo(ERROR_NO_FOLLOWING_PERMISSION)));
@@ -145,11 +140,7 @@ public void shouldReturnForbiddenForCreateApiKeyEndpointWhenUserHasNoRight() {
@Test
public void shouldReturnUnauthorizedWithoutAuthorizationForCreateApiKeyEndpoint() {
- restAssured
- .given()
- .when()
- .post(RESOURCE_URL)
- .then()
+ restAssured.given().when().post(RESOURCE_URL).then()
.statusCode(HttpStatus.UNAUTHORIZED.value());
assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations());
@@ -157,8 +148,7 @@ public void shouldReturnUnauthorizedWithoutAuthorizationForCreateApiKeyEndpoint(
@Test
public void shouldNotAllowToCreateApiKeyByAnotherApiKey() {
- post(API_KEY_TOKEN)
- .statusCode(HttpStatus.BAD_REQUEST.value())
+ post(API_KEY_TOKEN).statusCode(HttpStatus.BAD_REQUEST.value())
.body(MESSAGE_KEY, equalTo(ERROR_CLIENT_NOT_SUPPORTED));
assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations());
@@ -166,8 +156,7 @@ public void shouldNotAllowToCreateApiKeyByAnotherApiKey() {
@Test
public void shouldNotAllowToCreateApiKeyByService() {
- post(SERVICE_TOKEN)
- .statusCode(HttpStatus.BAD_REQUEST.value())
+ post(SERVICE_TOKEN).statusCode(HttpStatus.BAD_REQUEST.value())
.body(MESSAGE_KEY, equalTo(ERROR_CLIENT_NOT_SUPPORTED));
assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations());
@@ -200,10 +189,8 @@ public void shouldReturnForbiddenForGetApiKeysEndpointWhenUserHasNoRight() {
given(userReferenceDataService.hasRight(user.getId(), right.getId()))
.willReturn(new ResultDto<>(false));
- String response = get(10, USER_TOKEN)
- .statusCode(HttpStatus.FORBIDDEN.value())
- .extract()
- .path(MESSAGE_KEY);
+ String response =
+ get(10, USER_TOKEN).statusCode(HttpStatus.FORBIDDEN.value()).extract().path(MESSAGE_KEY);
assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations());
assertThat(response, is(equalTo(ERROR_NO_FOLLOWING_PERMISSION)));
@@ -211,20 +198,14 @@ public void shouldReturnForbiddenForGetApiKeysEndpointWhenUserHasNoRight() {
@Test
public void shouldReturnUnauthorizedWithoutAuthorizationForGetApiKeysEndpoint() {
- restAssured
- .given()
- .when()
- .get(RESOURCE_URL)
- .then()
- .statusCode(HttpStatus.UNAUTHORIZED.value());
+ restAssured.given().when().get(RESOURCE_URL).then().statusCode(HttpStatus.UNAUTHORIZED.value());
assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations());
}
@Test
public void shouldNotAllowToRetrieveApiKeysByAnotherApiKey() {
- get(10, API_KEY_TOKEN)
- .statusCode(HttpStatus.FORBIDDEN.value())
+ get(10, API_KEY_TOKEN).statusCode(HttpStatus.FORBIDDEN.value())
.body(MESSAGE_KEY, equalTo(ERROR_NO_FOLLOWING_PERMISSION));
assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations());
@@ -252,10 +233,8 @@ public void shouldReturnForbiddenForDeleteApiKeyEndpointWhenUserHasNoRight() {
given(userReferenceDataService.hasRight(user.getId(), right.getId()))
.willReturn(new ResultDto<>(false));
- String response = delete(USER_TOKEN)
- .statusCode(HttpStatus.FORBIDDEN.value())
- .extract()
- .path(MESSAGE_KEY);
+ String response =
+ delete(USER_TOKEN).statusCode(HttpStatus.FORBIDDEN.value()).extract().path(MESSAGE_KEY);
assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations());
assertThat(response, is(equalTo(ERROR_NO_FOLLOWING_PERMISSION)));
@@ -265,10 +244,8 @@ public void shouldReturnForbiddenForDeleteApiKeyEndpointWhenUserHasNoRight() {
public void shouldReturnNotFoundIfKeyNotExistForDeleteApiKeyEndpoint() {
given(apiKeyRepository.existsById(key.getToken())).willReturn(false);
- String response = delete(USER_TOKEN)
- .statusCode(HttpStatus.NOT_FOUND.value())
- .extract()
- .path(MESSAGE_KEY);
+ String response =
+ delete(USER_TOKEN).statusCode(HttpStatus.NOT_FOUND.value()).extract().path(MESSAGE_KEY);
assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations());
assertThat(response, is(equalTo(ERROR_API_KEY_NOT_FOUND)));
@@ -276,11 +253,9 @@ public void shouldReturnNotFoundIfKeyNotExistForDeleteApiKeyEndpoint() {
@Test
public void shouldNotAllowToRemoveKeyIfThereIsNoAuthentication() {
- given(tokenStore.readAuthentication(key.getToken().toString()))
- .willReturn(null);
+ given(tokenStore.readAuthentication(key.getToken().toString())).willReturn(null);
- delete(USER_TOKEN)
- .statusCode(HttpStatus.BAD_REQUEST.value())
+ delete(USER_TOKEN).statusCode(HttpStatus.BAD_REQUEST.value())
.body(MESSAGE_KEY, equalTo(ERROR_TOKEN_INVALID));
assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations());
@@ -288,11 +263,9 @@ public void shouldNotAllowToRemoveKeyIfThereIsNoAuthentication() {
@Test
public void shouldNotAllowToRemoveKeyIfThereIsNoClient() {
- given(clientRepository.findOneByClientId(CLIENT_ID))
- .willReturn(Optional.empty());
+ given(clientRepository.findOneByClientId(CLIENT_ID)).willReturn(Optional.empty());
- delete(USER_TOKEN)
- .statusCode(HttpStatus.NOT_FOUND.value())
+ delete(USER_TOKEN).statusCode(HttpStatus.NOT_FOUND.value())
.body(MESSAGE_KEY, equalTo(ERROR_CLIENT_NOT_FOUND));
assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations());
@@ -300,8 +273,7 @@ public void shouldNotAllowToRemoveKeyIfThereIsNoClient() {
@Test
public void shouldNotAllowToRemoveApiKeyByAnotherApiKey() {
- delete(API_KEY_TOKEN)
- .statusCode(HttpStatus.FORBIDDEN.value())
+ delete(API_KEY_TOKEN).statusCode(HttpStatus.FORBIDDEN.value())
.body(MESSAGE_KEY, equalTo(ERROR_NO_FOLLOWING_PERMISSION));
assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations());
@@ -309,48 +281,36 @@ public void shouldNotAllowToRemoveApiKeyByAnotherApiKey() {
@Test
public void shouldAllowToRemoveApiKeyByService() {
- delete(SERVICE_TOKEN)
- .statusCode(HttpStatus.NO_CONTENT.value());
+ delete(SERVICE_TOKEN).statusCode(HttpStatus.NO_CONTENT.value());
assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations());
}
@Test
public void shouldReturnUnauthorizedWithoutAuthorizationForDeleteApiKeyEndpoint() {
- restAssured
- .given()
- .pathParam(TOKEN, key.getToken())
- .when()
- .delete(TOKEN_URL)
- .then()
+ restAssured.given().pathParam(TOKEN, key.getToken()).when().delete(TOKEN_URL).then()
.statusCode(HttpStatus.UNAUTHORIZED.value());
assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations());
}
private ValidatableResponse post(String token) {
- return sendPostRequest(token, RESOURCE_URL, null, null)
- .contentType(is(APPLICATION_JSON_VALUE));
+ return sendPostRequest(token, RESOURCE_URL, null, null).contentType(is(APPLICATION_JSON_VALUE));
}
- private ValidatableResponse get(int pageSize, String token) {
+ private ValidatableResponse get(int pageSize,
+ String token) {
return get(pageSize, 0, token);
}
- private ValidatableResponse get(int pageSize, int page, String token) {
- return startRequest(token)
- .queryParam("page", page)
- .queryParam("size", pageSize)
- .when()
- .get(RESOURCE_URL)
- .then();
+ private ValidatableResponse get(int pageSize,
+ int page,
+ String token) {
+ return startRequest(token).queryParam("page", page).queryParam("size", pageSize).when()
+ .get(RESOURCE_URL).then();
}
private ValidatableResponse delete(String token) {
- return startRequest(token)
- .pathParam(TOKEN, key.getToken())
- .when()
- .delete(TOKEN_URL)
- .then();
+ return startRequest(token).pathParam(TOKEN, key.getToken()).when().delete(TOKEN_URL).then();
}
}
diff --git a/src/main/java/org/openlmis/auth/Application.java b/src/main/java/org/openlmis/auth/Application.java
index 4750368..3cd4338 100644
--- a/src/main/java/org/openlmis/auth/Application.java
+++ b/src/main/java/org/openlmis/auth/Application.java
@@ -29,6 +29,7 @@
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.i18n.CookieLocaleResolver;
@@ -95,4 +96,9 @@ public FlywayMigrationStrategy cleanMigrationStrategy() {
public Callback flywayCallback() {
return new ExportSchemaFlywayCallback();
}
+
+ @Bean
+ public LocalValidatorFactoryBean validator() {
+ return new LocalValidatorFactoryBean();
+ }
}
diff --git a/src/main/resources/applicationContext.xml b/src/main/resources/applicationContext.xml
index 5bd6dff..28ce4d9 100644
--- a/src/main/resources/applicationContext.xml
+++ b/src/main/resources/applicationContext.xml
@@ -10,7 +10,4 @@
-
-
diff --git a/src/test/java/org/openlmis/auth/ExportSchemaFlywayCallbackTest.java b/src/test/java/org/openlmis/auth/ExportSchemaFlywayCallbackTest.java
index aa49e9b..d35309e 100644
--- a/src/test/java/org/openlmis/auth/ExportSchemaFlywayCallbackTest.java
+++ b/src/test/java/org/openlmis/auth/ExportSchemaFlywayCallbackTest.java
@@ -17,7 +17,7 @@
import static org.flywaydb.core.api.callback.Event.AFTER_MIGRATE;
import static org.flywaydb.core.api.callback.Event.BEFORE_MIGRATE;
-import static org.mockito.Matchers.anyString;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
diff --git a/src/test/java/org/openlmis/auth/Resource2DbTest.java b/src/test/java/org/openlmis/auth/Resource2DbTest.java
index 2a3f36b..38a0e92 100644
--- a/src/test/java/org/openlmis/auth/Resource2DbTest.java
+++ b/src/test/java/org/openlmis/auth/Resource2DbTest.java
@@ -17,7 +17,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
diff --git a/src/test/java/org/openlmis/auth/domain/ConditionalUuidGeneratorTest.java b/src/test/java/org/openlmis/auth/domain/ConditionalUuidGeneratorTest.java
index 2085689..e0115fc 100644
--- a/src/test/java/org/openlmis/auth/domain/ConditionalUuidGeneratorTest.java
+++ b/src/test/java/org/openlmis/auth/domain/ConditionalUuidGeneratorTest.java
@@ -16,7 +16,7 @@
package org.openlmis.auth.domain;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import java.io.Serializable;
diff --git a/src/test/java/org/openlmis/auth/security/CustomTokenServicesTest.java b/src/test/java/org/openlmis/auth/security/CustomTokenServicesTest.java
index c366695..50a1dfe 100644
--- a/src/test/java/org/openlmis/auth/security/CustomTokenServicesTest.java
+++ b/src/test/java/org/openlmis/auth/security/CustomTokenServicesTest.java
@@ -16,8 +16,8 @@
package org.openlmis.auth.security;
import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
-import static org.mockito.Matchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
diff --git a/src/test/java/org/openlmis/auth/service/ExpirationTokenNotifierTest.java b/src/test/java/org/openlmis/auth/service/ExpirationTokenNotifierTest.java
index a09f99e..bc2a2c3 100644
--- a/src/test/java/org/openlmis/auth/service/ExpirationTokenNotifierTest.java
+++ b/src/test/java/org/openlmis/auth/service/ExpirationTokenNotifierTest.java
@@ -15,8 +15,8 @@
package org.openlmis.auth.service;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
diff --git a/src/test/java/org/openlmis/auth/service/PasswordResetNotifierTest.java b/src/test/java/org/openlmis/auth/service/PasswordResetNotifierTest.java
index 1560fef..da857c1 100644
--- a/src/test/java/org/openlmis/auth/service/PasswordResetNotifierTest.java
+++ b/src/test/java/org/openlmis/auth/service/PasswordResetNotifierTest.java
@@ -16,7 +16,7 @@
package org.openlmis.auth.service;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.openlmis.auth.i18n.MessageKeys.PASSWORD_RESET_EMAIL_BODY;
diff --git a/src/test/java/org/openlmis/auth/service/PermissionServiceTest.java b/src/test/java/org/openlmis/auth/service/PermissionServiceTest.java
index b612bdf..95ab591 100644
--- a/src/test/java/org/openlmis/auth/service/PermissionServiceTest.java
+++ b/src/test/java/org/openlmis/auth/service/PermissionServiceTest.java
@@ -16,7 +16,7 @@
package org.openlmis.auth.service;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.anyString;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
diff --git a/src/test/java/org/openlmis/auth/service/UserServiceTest.java b/src/test/java/org/openlmis/auth/service/UserServiceTest.java
index 1e5d501..bb5e47b 100644
--- a/src/test/java/org/openlmis/auth/service/UserServiceTest.java
+++ b/src/test/java/org/openlmis/auth/service/UserServiceTest.java
@@ -16,8 +16,8 @@
package org.openlmis.auth.service;
import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
-import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
diff --git a/src/test/java/org/openlmis/auth/service/consul/ConsulCommunicationServiceTest.java b/src/test/java/org/openlmis/auth/service/consul/ConsulCommunicationServiceTest.java
index 64991d1..2b2e994 100644
--- a/src/test/java/org/openlmis/auth/service/consul/ConsulCommunicationServiceTest.java
+++ b/src/test/java/org/openlmis/auth/service/consul/ConsulCommunicationServiceTest.java
@@ -16,8 +16,8 @@
package org.openlmis.auth.service.consul;
import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.given;
-import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -84,8 +84,7 @@ public void shouldUpdateOAuthResourcesWhenResourcesChanged() {
verify(clientRepository, atLeastOnce()).save(eq(client));
Set expectedResources = new HashSet<>(validServices);
- Set clientResources = Sets.newHashSet(
- client.getResourceIds().split(SERVICE_SEPARATOR));
+ Set clientResources = Sets.newHashSet(client.getResourceIds().split(SERVICE_SEPARATOR));
assertEquals(expectedResources, clientResources);
}
@@ -95,8 +94,8 @@ public void shouldNotUpdateOAuthResourcesWhenResourcesNotChanged() {
// given
mockConfigurationSettings();
- ServicesListDto expectedBody = generateServicesList(
- Collections.singletonList("referencedata"), Collections.singletonList("random-service"));
+ ServicesListDto expectedBody = generateServicesList(Collections.singletonList("referencedata"),
+ Collections.singletonList("random-service"));
mockExternalResponse(expectedBody);
Client client = new Client();
@@ -133,7 +132,8 @@ private void mockExternalResponse(ServicesListDto body) {
.willReturn(expectedResponse);
}
- private ServicesListDto generateServicesList(List valid, List invalid) {
+ private ServicesListDto generateServicesList(List valid,
+ List invalid) {
ServicesListDto services = new ServicesListDto();
String serviceTag = configurationSettingService.getConsulServiceTag();
diff --git a/src/test/java/org/openlmis/auth/service/notification/NotificationServiceTest.java b/src/test/java/org/openlmis/auth/service/notification/NotificationServiceTest.java
index 7ec5c09..2633cf4 100644
--- a/src/test/java/org/openlmis/auth/service/notification/NotificationServiceTest.java
+++ b/src/test/java/org/openlmis/auth/service/notification/NotificationServiceTest.java
@@ -19,8 +19,8 @@
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.openlmis.auth.service.notification.NotificationChannelDto.EMAIL;
diff --git a/src/test/java/org/openlmis/auth/service/notification/UserContactDetailsNotificationServiceTest.java b/src/test/java/org/openlmis/auth/service/notification/UserContactDetailsNotificationServiceTest.java
index 0cbc15a..7892747 100644
--- a/src/test/java/org/openlmis/auth/service/notification/UserContactDetailsNotificationServiceTest.java
+++ b/src/test/java/org/openlmis/auth/service/notification/UserContactDetailsNotificationServiceTest.java
@@ -16,8 +16,8 @@
package org.openlmis.auth.service.notification;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
diff --git a/src/test/java/org/openlmis/auth/service/referencedata/UserReferenceDataServiceTest.java b/src/test/java/org/openlmis/auth/service/referencedata/UserReferenceDataServiceTest.java
index 8de295f..61d8065 100644
--- a/src/test/java/org/openlmis/auth/service/referencedata/UserReferenceDataServiceTest.java
+++ b/src/test/java/org/openlmis/auth/service/referencedata/UserReferenceDataServiceTest.java
@@ -18,8 +18,8 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
diff --git a/src/test/java/org/openlmis/auth/util/AuthenticationHelperTest.java b/src/test/java/org/openlmis/auth/util/AuthenticationHelperTest.java
index 27d0d7c0..3b38a85 100644
--- a/src/test/java/org/openlmis/auth/util/AuthenticationHelperTest.java
+++ b/src/test/java/org/openlmis/auth/util/AuthenticationHelperTest.java
@@ -17,7 +17,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
diff --git a/src/test/java/org/openlmis/auth/web/DefaultContentTypeInterceptorTest.java b/src/test/java/org/openlmis/auth/web/DefaultContentTypeInterceptorTest.java
index 40271e6..2b8dca3 100644
--- a/src/test/java/org/openlmis/auth/web/DefaultContentTypeInterceptorTest.java
+++ b/src/test/java/org/openlmis/auth/web/DefaultContentTypeInterceptorTest.java
@@ -16,7 +16,7 @@
package org.openlmis.auth.web;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.anyString;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
diff --git a/src/test/java/org/openlmis/auth/web/PasswordResetRequestDtoValidatorTest.java b/src/test/java/org/openlmis/auth/web/PasswordResetRequestDtoValidatorTest.java
index 3cef78e..9afc7a2 100644
--- a/src/test/java/org/openlmis/auth/web/PasswordResetRequestDtoValidatorTest.java
+++ b/src/test/java/org/openlmis/auth/web/PasswordResetRequestDtoValidatorTest.java
@@ -16,8 +16,8 @@
package org.openlmis.auth.web;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.when;
diff --git a/src/test/java/org/openlmis/auth/web/UserDtoValidatorTest.java b/src/test/java/org/openlmis/auth/web/UserDtoValidatorTest.java
index 4e3ae25..f7ce652 100644
--- a/src/test/java/org/openlmis/auth/web/UserDtoValidatorTest.java
+++ b/src/test/java/org/openlmis/auth/web/UserDtoValidatorTest.java
@@ -16,8 +16,8 @@
package org.openlmis.auth.web;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.when;
import static org.openlmis.auth.i18n.MessageKeys.ERROR_USER_NOT_FOUND;
import static org.openlmis.auth.service.PermissionService.USERS_MANAGE;
diff --git a/src/test/java/org/openlmis/auth/web/WebErrorHandlingTest.java b/src/test/java/org/openlmis/auth/web/WebErrorHandlingTest.java
index 431278b..bba8425 100644
--- a/src/test/java/org/openlmis/auth/web/WebErrorHandlingTest.java
+++ b/src/test/java/org/openlmis/auth/web/WebErrorHandlingTest.java
@@ -16,7 +16,7 @@
package org.openlmis.auth.web;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.openlmis.auth.i18n.MessageKeys.ERROR_CONSTRAINT;