Search in sources :

Example 1 with TestDto2

use of integr.org.summerb.jdbccrud.TestDto2 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));
}
Also used : DataSetLoaderImpl(org.summerb.approaches.jdbccrud.impl.relations.DataSetLoaderImpl) EasyCrudService(org.summerb.approaches.jdbccrud.api.EasyCrudService) HashSet(java.util.HashSet) Set(java.util.Set) DataSet(org.summerb.approaches.jdbccrud.api.dto.datapackage.DataSet) DataSet(org.summerb.approaches.jdbccrud.api.dto.datapackage.DataSet) HashMap(java.util.HashMap) TestDto1(integr.org.summerb.jdbccrud.TestDto1) TestDto2(integr.org.summerb.jdbccrud.TestDto2) Test(org.junit.Test)

Aggregations

TestDto1 (integr.org.summerb.jdbccrud.TestDto1)1 TestDto2 (integr.org.summerb.jdbccrud.TestDto2)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Test (org.junit.Test)1 EasyCrudService (org.summerb.approaches.jdbccrud.api.EasyCrudService)1 DataSet (org.summerb.approaches.jdbccrud.api.dto.datapackage.DataSet)1 DataSetLoaderImpl (org.summerb.approaches.jdbccrud.impl.relations.DataSetLoaderImpl)1