Search in sources :

Example 11 with DataSetLoader

use of org.summerb.approaches.jdbccrud.api.relations.DataSetLoader in project summerb by skarpushin.

the class DataSetLoaderTest method testResolveReferencedObjects_ExpectOneToManyRecoursiveLoadedOk.

@Test
public void testResolveReferencedObjects_ExpectOneToManyRecoursiveLoadedOk() throws EntityNotFoundException, NotAuthorizedException, FieldValidationException {
    DataSetLoader loader = buildLoaderCase1();
    TestDto2 d2i1 = new TestDto2();
    d2i1.setEnv("required");
    d2i1.setLinkToFullDonwload("required");
    d2i1 = testDto2Service.create(d2i1);
    TestDto3 d3i1 = new TestDto3();
    d3i1.setLinkToDtoTwo(d2i1.getId());
    d3i1 = testDto3Service.create(d3i1);
    TestDto1 d1i1 = new TestDto1();
    d1i1.setEnv("d1i1");
    d1i1.setLinkToFullDonwload("required");
    d1i1 = testDto1Service.create(d1i1);
    TestDto3 d3i2 = new TestDto3();
    d3i2.setLinkToDtoTwo(d2i1.getId());
    d3i2.setLinkToDtoOneOptional(d1i1.getId());
    d3i2 = testDto3Service.create(d3i2);
    DataSet result = new DataSet();
    result.get(testDto2Service.getEntityTypeMessageCode()).put(d2i1);
    loader.resolveReferencedObjects(result, Refs.ref3to2mand.reverse(), Refs.ref3to1);
    assertNotNull(result.get(testDto3Service.getEntityTypeMessageCode()).find(d3i1.getId()));
    assertNotNull(result.get(testDto3Service.getEntityTypeMessageCode()).find(d3i2.getId()));
    assertNotNull(result.get(testDto1Service.getEntityTypeMessageCode()).find(d1i1.getId()));
}
Also used : DataSet(org.summerb.approaches.jdbccrud.api.dto.datapackage.DataSet) DataSetLoader(org.summerb.approaches.jdbccrud.api.relations.DataSetLoader) Test(org.junit.Test)

Aggregations

DataSetLoader (org.summerb.approaches.jdbccrud.api.relations.DataSetLoader)11 Test (org.junit.Test)10 DataSet (org.summerb.approaches.jdbccrud.api.dto.datapackage.DataSet)9 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Set (java.util.Set)3 HasId (org.summerb.approaches.jdbccrud.api.dto.HasId)3 Preconditions (com.google.common.base.Preconditions)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 BeansException (org.springframework.beans.BeansException)1 InitializingBean (org.springframework.beans.factory.InitializingBean)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 ApplicationContext (org.springframework.context.ApplicationContext)1 ApplicationContextAware (org.springframework.context.ApplicationContextAware)1 MediaType (org.springframework.http.MediaType)1 CollectionUtils (org.springframework.util.CollectionUtils)1 DeleteMapping (org.springframework.web.bind.annotation.DeleteMapping)1