use of org.summerb.approaches.jdbccrud.impl.relations.DataSetLoaderImpl in project summerb by skarpushin.
the class DataSetLoaderImplTest method testLoadObjectsByIds_ExpectTwoDifferentObjectsLoadedOk.
@Test
public void testLoadObjectsByIds_ExpectTwoDifferentObjectsLoadedOk() throws Exception {
DataSetLoaderImpl fixture = buildMockedInstance();
EasyCrudService service1 = Mockito.mock(EasyCrudService.class);
when(fixture.getEasyCrudServiceResolver().resolveByEntityType("dto1")).thenReturn(service1);
TestDto1 dto1 = new TestDto1();
dto1.setId("d1");
when(service1.findById("d1")).thenReturn(dto1);
EasyCrudService service2 = Mockito.mock(EasyCrudService.class);
when(fixture.getEasyCrudServiceResolver().resolveByEntityType("dto2")).thenReturn(service2);
TestDto2 dto2 = new TestDto2();
dto2.setId(2L);
when(service2.findById(2L)).thenReturn(dto2);
DataSet ret = new DataSet();
Map<String, Set<Object>> ids = new HashMap<>();
ids.put("dto1", ids("d1"));
ids.put("dto2", ids(2L));
fixture.loadObjectsByIds(ids, ret);
assertNotNull(ret.get("dto1"));
assertNotNull(ret.get("dto1").find("d1"));
assertNotNull(ret.get("dto2"));
assertNotNull(ret.get("dto2").find(2L));
}
use of org.summerb.approaches.jdbccrud.impl.relations.DataSetLoaderImpl in project summerb by skarpushin.
the class DataSetLoaderImplTest method testLoadObjectsByIds_ExpectOneLoadNfe.
@Test(expected = GenericEntityNotFoundException.class)
public void testLoadObjectsByIds_ExpectOneLoadNfe() throws Exception {
DataSetLoaderImpl fixture = buildMockedInstance();
EasyCrudService service = Mockito.mock(EasyCrudService.class);
when(fixture.getEasyCrudServiceResolver().resolveByEntityType("dto1")).thenReturn(service);
when(service.findById(1)).thenReturn(null);
fixture.loadObjectsByIds(ids(1), "dto1");
}
use of org.summerb.approaches.jdbccrud.impl.relations.DataSetLoaderImpl in project summerb by skarpushin.
the class DataSetLoaderImplTest method testLoadObjectsByIds_ExpectManyLoadByLongsNfe.
@Test(expected = GenericEntityNotFoundException.class)
public void testLoadObjectsByIds_ExpectManyLoadByLongsNfe() throws Exception {
DataSetLoaderImpl fixture = buildMockedInstance();
EasyCrudService service = Mockito.mock(EasyCrudService.class);
when(fixture.getEasyCrudServiceResolver().resolveByEntityType("dto1")).thenReturn(service);
PaginatedList mockret = new PaginatedList<>(new PagerParams(), Collections.emptyList(), 0);
when(service.query(any(PagerParams.class), any(Query.class))).thenReturn(mockret);
fixture.loadObjectsByIds(ids(1L, 2L), "dto1");
}
use of org.summerb.approaches.jdbccrud.impl.relations.DataSetLoaderImpl in project summerb by skarpushin.
the class DataSetLoaderImplTest method testLoadObjectsByIds_ExpectIaeForEmptyIds2.
@Test(expected = IllegalArgumentException.class)
public void testLoadObjectsByIds_ExpectIaeForEmptyIds2() throws Exception {
DataSetLoaderImpl fixture = buildMockedInstance();
fixture.loadObjectsByIds(new HashSet<>(), "asdasd");
}
use of org.summerb.approaches.jdbccrud.impl.relations.DataSetLoaderImpl in project summerb by skarpushin.
the class DataSetLoaderImplTest method testLoadObjectsByIds_ExpectIaeForEmptyIds.
@Test(expected = IllegalArgumentException.class)
public void testLoadObjectsByIds_ExpectIaeForEmptyIds() throws Exception {
DataSetLoaderImpl fixture = buildMockedInstance();
fixture.loadObjectsByIds(null, "asdasd");
}
Aggregations