Skip to content

Commit

Permalink
Update Mockito and resolve dependency clashes
Browse files Browse the repository at this point in the history
  • Loading branch information
derjust committed Dec 17, 2017
1 parent 79de7b9 commit e3fcb31
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 119 deletions.
3 changes: 3 additions & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
<action dev="derjust" type="add" date="2017-12-01" >
Added maven-changes-plugin to build process
</action>
<action dev="derjust" type="add" date="2017-12-17" >
Update Mockito and resolve dependency clashes
</action>
</release>
<release version="5.0.0" date="2017-11-27" description="Spring 5 release" >
<action dev="derjust" type="add">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.MockitoJUnitRunner;
import org.socialsignin.spring.data.dynamodb.domain.sample.Playlist;
import org.socialsignin.spring.data.dynamodb.domain.sample.User;

Expand Down Expand Up @@ -38,7 +38,7 @@ public void setUp() {
@Test
public void testBatchDelete_CallsCorrectDynamoDBMapperMethod()
{
List<User> users = new ArrayList<User>();
List<User> users = new ArrayList<>();
dynamoDBTemplate.batchDelete(users);
Mockito.verify(dynamoDBMapper).batchDelete(Mockito.any(List.class));
}
Expand All @@ -47,7 +47,7 @@ public void testBatchDelete_CallsCorrectDynamoDBMapperMethod()
@Test
public void testBatchSave_CallsCorrectDynamoDBMapperMethod()
{
List<User> users = new ArrayList<User>();
List<User> users = new ArrayList<>();
dynamoDBTemplate.batchSave(users);
Mockito.verify(dynamoDBMapper).batchSave(Mockito.any(List.class));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.MockitoJUnitRunner;
import org.socialsignin.spring.data.dynamodb.domain.sample.User;

import static org.hamcrest.CoreMatchers.is;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.MockitoJUnitRunner;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.MockitoJUnitRunner;
import org.socialsignin.spring.data.dynamodb.domain.sample.Playlist;
import org.socialsignin.spring.data.dynamodb.repository.support.DynamoDBIdIsHashAndRangeKeyEntityInformation;

Expand All @@ -22,7 +22,7 @@ public void setUp()
{
Mockito.when(entityInformation.getHashKeyPropertyName()).thenReturn("userName");
Mockito.when(entityInformation.getRangeKeyPropertyName()).thenReturn("playlistName");
criteria = new DynamoDBEntityWithHashAndRangeKeyCriteria<Playlist,String>(entityInformation, null);
criteria = new DynamoDBEntityWithHashAndRangeKeyCriteria<>(entityInformation, null);
}

@Test
Expand Down Expand Up @@ -119,7 +119,6 @@ public void testHasIndexRangeKeyCondition_WhenConditionCriteriaIsEqualityOnAProp
@Test
public void testHasIndexRangeKeyCondition_WhenConditionCriteriaIsEqualityOnAPropertyWhichIsNotAnIndexRangeKeyButIsARangeKey()
{
Mockito.when(entityInformation.isGlobalIndexRangeKeyProperty("playlistName")).thenReturn(false);
criteria.withPropertyEquals("playlist name", "some playlist name", String.class);
boolean hasIndexRangeKeyCondition = criteria.hasIndexRangeKeyCondition();
Assert.assertFalse(hasIndexRangeKeyCondition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.MockitoJUnitRunner;
import org.socialsignin.spring.data.dynamodb.domain.sample.User;
import org.socialsignin.spring.data.dynamodb.repository.support.DynamoDBEntityInformation;

Expand All @@ -23,7 +23,7 @@ public class DynamoDBEntityWithHashKeyOnlyCriteriaUnitTest extends AbstractDynam
public void setUp()
{
Mockito.when(entityInformation.getHashKeyPropertyName()).thenReturn("id");
criteria = new DynamoDBEntityWithHashKeyOnlyCriteria<User,String>(entityInformation, null);
criteria = new DynamoDBEntityWithHashKeyOnlyCriteria<>(entityInformation, null);
}

@Test
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.MockitoJUnitRunner;
import org.socialsignin.spring.data.dynamodb.domain.sample.User;

@RunWith(MockitoJUnitRunner.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.MockitoJUnitRunner;
import org.socialsignin.spring.data.dynamodb.domain.sample.PlaylistId;

import java.lang.reflect.Method;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.MockitoJUnitRunner;
import org.socialsignin.spring.data.dynamodb.domain.sample.Playlist;
import org.socialsignin.spring.data.dynamodb.domain.sample.PlaylistId;
import org.socialsignin.spring.data.dynamodb.domain.sample.User;
Expand Down Expand Up @@ -55,25 +55,16 @@ public void setup()
Mockito.when(mockHashAndRangeKeyExtractor.getHashKey(mockPlaylistId)).thenReturn(mockHashKey);
Mockito.when(mockHashAndRangeKeyExtractor.getRangeKey(mockPlaylistId)).thenReturn(mockRangeKey);

Mockito.when(mockUserEntityMetadata.getHashKeyPropertyName()).thenReturn("userHashKeyPropertyName");
Mockito.when(mockPlaylistEntityMetadata.getHashKeyPropertyName()).thenReturn("playlistHashKeyPropertyName");
Mockito.when(mockUserEntityMetadata.getHashKeyPropotypeEntityForHashKey("someUserHashKey")).thenReturn(mockUserPrototype);
Mockito.when(mockPlaylistEntityMetadata.getHashKeyPropotypeEntityForHashKey("somePlaylistHashKey")).thenReturn(mockPlaylistPrototype);
Mockito.when(mockUserEntityMetadata.getMarshallerForProperty("marshalledProperty")).thenReturn(mockPropertyMarshaller);
Mockito.when(mockPlaylistEntityMetadata.getMarshallerForProperty("marshalledProperty")).thenReturn(mockPropertyMarshaller);
Mockito.when(mockUserEntityMetadata.getOverriddenAttributeName("overriddenProperty")).thenReturn("modifiedPropertyName");
Mockito.when(mockPlaylistEntityMetadata.getOverriddenAttributeName("overriddenProperty")).thenReturn("modifiedPropertyName");

Mockito.when(mockUserEntityMetadata.isHashKeyProperty("hashKeyProperty")).thenReturn(true);
Mockito.when(mockPlaylistEntityMetadata.isHashKeyProperty("hashKeyProperty")).thenReturn(true);
Mockito.when(mockUserEntityMetadata.isHashKeyProperty("nonHashKeyProperty")).thenReturn(false);
Mockito.when(mockPlaylistEntityMetadata.isHashKeyProperty("nonHashKeyProperty")).thenReturn(false);
Mockito.when(mockUserEntityMetadata.isCompositeHashAndRangeKeyProperty("compositeIdProperty")).thenReturn(true);
Mockito.when(mockPlaylistEntityMetadata.isCompositeHashAndRangeKeyProperty("compositeIdProperty")).thenReturn(true);
Mockito.when(mockUserEntityMetadata.isCompositeHashAndRangeKeyProperty("nonCompositeIdProperty")).thenReturn(false);
Mockito.when(mockPlaylistEntityMetadata.isCompositeHashAndRangeKeyProperty("nonCompositeIdProperty")).thenReturn(false);

dynamoDBPlaylistEntityInformation = new DynamoDBIdIsHashAndRangeKeyEntityInformationImpl<Playlist,PlaylistId>(Playlist.class,mockPlaylistEntityMetadata);
dynamoDBPlaylistEntityInformation = new DynamoDBIdIsHashAndRangeKeyEntityInformationImpl<>(Playlist.class,mockPlaylistEntityMetadata);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.MockitoJUnitRunner;
import org.socialsignin.spring.data.dynamodb.domain.sample.Playlist;
import org.socialsignin.spring.data.dynamodb.domain.sample.PlaylistId;
import org.socialsignin.spring.data.dynamodb.domain.sample.User;
Expand Down Expand Up @@ -46,21 +46,16 @@ public void setup()

Mockito.when(mockUserEntityMetadata.getHashKeyPropertyName()).thenReturn("userHashKeyPropertyName");
Mockito.when(mockPlaylistEntityMetadata.getHashKeyPropertyName()).thenReturn("playlistHashKeyPropertyName");
Mockito.when(mockPlaylistEntityMetadata.getHashKeyPropotypeEntityForHashKey("somePlaylistHashKey")).thenReturn(mockPlaylistPrototype);
Mockito.when(mockUserEntityMetadata.getMarshallerForProperty("marshalledProperty")).thenReturn(mockPropertyMarshaller);
Mockito.when(mockPlaylistEntityMetadata.getMarshallerForProperty("marshalledProperty")).thenReturn(mockPropertyMarshaller);
Mockito.when(mockUserEntityMetadata.getOverriddenAttributeName("overriddenProperty")).thenReturn("modifiedPropertyName");
Mockito.when(mockPlaylistEntityMetadata.getOverriddenAttributeName("overriddenProperty")).thenReturn("modifiedPropertyName");

Mockito.when(mockUserEntityMetadata.isHashKeyProperty("hashKeyProperty")).thenReturn(true);
Mockito.when(mockPlaylistEntityMetadata.isHashKeyProperty("hashKeyProperty")).thenReturn(true);
Mockito.when(mockUserEntityMetadata.isHashKeyProperty("nonHashKeyProperty")).thenReturn(false);
Mockito.when(mockPlaylistEntityMetadata.isHashKeyProperty("nonHashKeyProperty")).thenReturn(false);
Mockito.when(mockPlaylistEntityMetadata.isCompositeHashAndRangeKeyProperty("compositeIdProperty")).thenReturn(true);
Mockito.when(mockPlaylistEntityMetadata.isCompositeHashAndRangeKeyProperty("nonCompositeIdProperty")).thenReturn(false);

dynamoDBPlaylistEntityInformation = new DynamoDBIdIsHashKeyEntityInformationImpl<Playlist,PlaylistId>(Playlist.class,mockPlaylistEntityMetadata);
dynamoDBUserEntityInformation = new DynamoDBIdIsHashKeyEntityInformationImpl<User,String>(User.class,mockUserEntityMetadata);

dynamoDBPlaylistEntityInformation = new DynamoDBIdIsHashKeyEntityInformationImpl<>(Playlist.class,mockPlaylistEntityMetadata);
dynamoDBUserEntityInformation = new DynamoDBIdIsHashKeyEntityInformationImpl<>(User.class,mockUserEntityMetadata);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.MockitoJUnitRunner;
import org.socialsignin.spring.data.dynamodb.core.DynamoDBOperations;
import org.socialsignin.spring.data.dynamodb.domain.sample.Playlist;
import org.socialsignin.spring.data.dynamodb.domain.sample.PlaylistId;
Expand Down Expand Up @@ -77,9 +77,9 @@ public void setUp() {
when(entityWithSimpleIdInformation.getJavaType()).thenReturn(User.class);
when(entityWithSimpleIdInformation.getHashKey(1l)).thenReturn(1l);

when(mockEnableScanPermissions.isFindAllUnpaginatedScanEnabled()).thenReturn(true);
when(mockEnableScanPermissions.isDeleteAllUnpaginatedScanEnabled()).thenReturn(true);
when(mockEnableScanPermissions.isCountUnpaginatedScanEnabled()).thenReturn(true);
// when(mockEnableScanPermissions.isFindAllUnpaginatedScanEnabled()).thenReturn(true);
// when(mockEnableScanPermissions.isDeleteAllUnpaginatedScanEnabled()).thenReturn(true);
// when(mockEnableScanPermissions.isCountUnpaginatedScanEnabled()).thenReturn(true);


when(entityWithCompositeIdInformation.getJavaType()).thenReturn(Playlist.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.MockitoJUnitRunner;
import org.socialsignin.spring.data.dynamodb.core.DynamoDBOperations;
import org.socialsignin.spring.data.dynamodb.domain.sample.Playlist;
import org.socialsignin.spring.data.dynamodb.domain.sample.PlaylistId;
Expand Down Expand Up @@ -77,19 +77,14 @@ public void setUp() {
when(entityWithOnlyHashKeyInformation.getHashKey(1l)).thenReturn(1l);


when(mockEnableScanPermissions.isFindAllUnpaginatedScanEnabled()).thenReturn(true);
when(mockEnableScanPermissions.isDeleteAllUnpaginatedScanEnabled()).thenReturn(true);
when(mockEnableScanPermissions.isCountUnpaginatedScanEnabled()).thenReturn(true);


when(entityWithHashAndRangeKeyInformation.getJavaType()).thenReturn(Playlist.class);
when(entityWithHashAndRangeKeyInformation.getHashKey(testPlaylistId)).thenReturn("michael");
when(entityWithHashAndRangeKeyInformation.getRangeKey(testPlaylistId)).thenReturn("playlist1");
when(entityWithHashAndRangeKeyInformation.isRangeKeyAware()).thenReturn(true);

repoForEntityWithOnlyHashKey = new SimpleDynamoDBPagingAndSortingRepository<User, Long>(entityWithOnlyHashKeyInformation,
repoForEntityWithOnlyHashKey = new SimpleDynamoDBPagingAndSortingRepository<>(entityWithOnlyHashKeyInformation,
dynamoDBOperations,mockEnableScanPermissions);
repoForEntityWithHashAndRangeKey = new SimpleDynamoDBPagingAndSortingRepository<Playlist, PlaylistId>(
repoForEntityWithHashAndRangeKey = new SimpleDynamoDBPagingAndSortingRepository<>(
entityWithHashAndRangeKeyInformation, dynamoDBOperations,mockEnableScanPermissions);

when(dynamoDBOperations.load(User.class, 1l)).thenReturn(testUser);
Expand Down

0 comments on commit e3fcb31

Please sign in to comment.