use of tech.sirwellington.alchemy.generator.AlchemyGenerator in project aroma-data-operations by RedRoma.
the class CassandraTokenRepositoryTest method testGetTokensBelongingTo.
@Test
public void testGetTokensBelongingTo() throws Exception {
AlchemyGenerator<AuthenticationToken> generator = pojos(AuthenticationToken.class);
Set<AuthenticationToken> expected = listOf(generator).stream().map(t -> t.setOwnerId(ownerId)).map(t -> t.setTokenId(one(uuids))).map(t -> t.setOrganizationId(one(uuids))).collect(toSet());
Map<AuthenticationToken, Row> rows = Maps.create();
for (AuthenticationToken t : expected) {
Row mockRow = mock(Row.class);
when(tokenMapper.apply(mockRow)).thenReturn(t);
rows.put(t, mockRow);
}
when(results.iterator()).thenReturn(rows.values().iterator());
Set<AuthenticationToken> result = Sets.toSet(instance.getTokensBelongingTo(ownerId));
assertThat(result, is(expected));
}
Aggregations