Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Commit

Permalink
Cleanup build warnings (#356)
Browse files Browse the repository at this point in the history
Fix all the build warnings:
 - "scheduling-manager:compileTestJavaNote: Some input files use or
 override a deprecated API."
 - "EnvironmentRepositoryDDBTest.java uses unchecked or unsafe
 operations."
 - "ERROR StatusLogger No log4j2 configuration file found....."
  • Loading branch information
wbingli authored Jan 26, 2018
1 parent c57c1ef commit fc1507c
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 25 deletions.
13 changes: 13 additions & 0 deletions buildSrc/src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="error">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 16,10 @@

import static com.amazonaws.blox.dataservice.repository.model.EnvironmentDDBRecord.ENVIRONMENT_NAME_RANGE_KEY;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.never;
Expand All @@ -38,7 39,6 @@
import com.amazonaws.blox.dataservicemodel.v1.exception.InternalServiceException;
import com.amazonaws.blox.dataservicemodel.v1.exception.ResourceNotFoundException;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBQueryExpression;
import com.amazonaws.services.dynamodbv2.datamodeling.PaginatedQueryList;
import com.amazonaws.services.dynamodbv2.model.AttributeValue;
Expand All @@ -64,8 64,6 @@ public class EnvironmentRepositoryDDBTest {
private static final String CLUSTER = "mycluster";
private static final String ENVIRONMENT_NAME = "myenv";
private static final String ENVIRONMENT_REVISION_ID = "revision-id";
private static final DynamoDBMapperConfig CONFIG =
DynamoDBMapperConfig.SaveBehavior.CLOBBER.config();

@Rule public ExpectedException thrown = ExpectedException.none();

Expand All @@ -79,7 77,9 @@ public class EnvironmentRepositoryDDBTest {

@InjectMocks private EnvironmentRepositoryDDB environmentRepositoryDDB;

@Captor private ArgumentCaptor<DynamoDBQueryExpression> ddbQueryExpressionCaptor;
@Captor
private ArgumentCaptor<DynamoDBQueryExpression<EnvironmentDDBRecord>> ddbQueryExpressionCaptor;

@Captor private ArgumentCaptor<EnvironmentDDBRecord> environmentDDBRecordArgumentCaptor;

private EnvironmentId environmentId;
Expand Down Expand Up @@ -163,8 163,9 @@ public void testListEnvironmentsWithEnvironmentNamePrefix() throws Exception {
final String environmentNamePrefix = "environmentNamePrefix";

when(environmentDDBRecords.stream()).thenReturn(Stream.of(environmentDDBRecord));
when(dynamoDBMapper.query(eq(EnvironmentDDBRecord.class), any(DynamoDBQueryExpression.class)))
.thenReturn(environmentDDBRecords);
doReturn(environmentDDBRecords)
.when(dynamoDBMapper)
.query(eq(EnvironmentDDBRecord.class), any());
when(environmentMapper.toEnvironment(environmentDDBRecord)).thenReturn(environment);

final List<Environment> result =
Expand All @@ -175,7 176,7 @@ public void testListEnvironmentsWithEnvironmentNamePrefix() throws Exception {
verify(environmentMapper).toEnvironment(environmentDDBRecord);

final EnvironmentDDBRecord queriedEnvironmentDDBRecord =
(EnvironmentDDBRecord) ddbQueryExpressionCaptor.getValue().getHashKeyValues();
ddbQueryExpressionCaptor.getValue().getHashKeyValues();
final Map<String, Condition> queryConditions =
ddbQueryExpressionCaptor.getValue().getRangeKeyConditions();

Expand All @@ -195,8 196,9 @@ public void testListEnvironmentsWithEnvironmentNamePrefix() throws Exception {
@Test
public void testListEnvironmentsWithoutEnvironmentNamePrefix() throws Exception {
when(environmentDDBRecords.stream()).thenReturn(Stream.of(environmentDDBRecord));
when(dynamoDBMapper.query(eq(EnvironmentDDBRecord.class), any(DynamoDBQueryExpression.class)))
.thenReturn(environmentDDBRecords);
doReturn(environmentDDBRecords)
.when(dynamoDBMapper)
.query(eq(EnvironmentDDBRecord.class), any());
when(environmentMapper.toEnvironment(environmentDDBRecord)).thenReturn(environment);

final List<Environment> result = environmentRepositoryDDB.listEnvironments(cluster, null);
Expand All @@ -206,7 208,7 @@ public void testListEnvironmentsWithoutEnvironmentNamePrefix() throws Exception
verify(environmentMapper).toEnvironment(environmentDDBRecord);

final EnvironmentDDBRecord queriedEnvironmentDDBRecord =
(EnvironmentDDBRecord) ddbQueryExpressionCaptor.getValue().getHashKeyValues();
ddbQueryExpressionCaptor.getValue().getHashKeyValues();

assertThat(ddbQueryExpressionCaptor.getValue().getRangeKeyConditions()).isNull();
assertThat(queriedEnvironmentDDBRecord.getAccountIdCluster())
Expand All @@ -218,8 220,9 @@ public void testListEnvironmentsWithoutEnvironmentNamePrefix() throws Exception
@Test
public void testListEnvironmentsEmptyResult() throws Exception {
when(environmentDDBRecords.stream()).thenReturn(Stream.empty());
when(dynamoDBMapper.query(eq(EnvironmentDDBRecord.class), any(DynamoDBQueryExpression.class)))
.thenReturn(environmentDDBRecords);
doReturn(environmentDDBRecords)
.when(dynamoDBMapper)
.query(eq(EnvironmentDDBRecord.class), any());

final List<Environment> result = environmentRepositoryDDB.listEnvironments(cluster, null);

Expand All @@ -230,8 233,9 @@ public void testListEnvironmentsEmptyResult() throws Exception {

@Test
public void testListEnvironmentsInternalError() throws Exception {
when(dynamoDBMapper.query(eq(EnvironmentDDBRecord.class), any(DynamoDBQueryExpression.class)))
.thenThrow(AmazonServiceException.class);
doThrow(AmazonServiceException.class)
.when(dynamoDBMapper)
.query(eq(EnvironmentDDBRecord.class), any());

thrown.expect(InternalServiceException.class);
thrown.expectMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 16,7 @@

import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 17,7 @@
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 16,7 @@

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 35,7 @@
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.MockitoJUnitRunner;

@RunWith(MockitoJUnitRunner.class)
public class ManagerHandlerTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 16,7 @@

import static org.hamcrest.CoreMatchers.hasItems;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.when;

import com.amazonaws.blox.dataservicemodel.v1.client.DataService;
Expand All @@ -31,7 31,7 @@
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.MockitoJUnitRunner;

@RunWith(MockitoJUnitRunner.class)
public class ReconcilerHandlerTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 16,7 @@

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 46,7 @@
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.MockitoJUnitRunner;
import software.amazon.awssdk.services.ecs.ECSAsyncClient;

@RunWith(MockitoJUnitRunner.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 17,7 @@
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.empty;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 17,7 @@
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.empty;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand Down

0 comments on commit fc1507c

Please sign in to comment.