MetatableTransformer { public MetatableEntity metafileDTOtoEntity(MetatableDTO metatableDTO) { MetatableEntity metatableEntity = new MetatableEntity(); metatableEntity.setUuid(metatableDTO.getUuid() != null ? metatableDTO.getUuid() : null); metatableEntity.setType( metatableDTO.getType() != null ? metatableDTO.getType() : null); Set<MetafileEntity> metafileEntitySet = new HashSet<>(); metatableDTO.getMetafileSet().forEach(metafileDTO -> metafileEntitySet .add(metafileTransformer.metafileDTOtoEntity(metafileDTO))); metatableEntity.setMetafileSet(metafileEntitySet); metatableEntity.setLastUpdateTimestamp(metatableDTO.getLastUpdateTimestamp() != null ? metatableDTO.getLastUpdateTimestamp() : null); metatableEntity.setVersion(metatableDTO.getVersion() != null ? metatableDTO.getVersion() : null); return metatableEntity; } MetatableTransformer(); MetatableDTO metafileEntityToDTO(MetatableEntity metatableEntity); MetatableEntity metafileDTOtoEntity(MetatableDTO metatableDTO);  }
@Test public void metafileDTOtoEntity() throws Exception { MetatableTransformer metatableTransformer = new MetatableTransformer(); MetatableDTO metatableDTO = TestHelper .getMetatableDTO(UUID.randomUUID().toString(), "0.0.0", MetatableType.MASTER, new DateTime().getTimeInMillisec()); MetatableEntity metatableEntity = metatableTransformer.metafileDTOtoEntity(metatableDTO); assertEquals(metatableEntity.getType(), metatableDTO.getType()); assertEquals(metatableEntity.getVersion(), metatableDTO.getVersion()); assertEquals(metatableEntity.getUuid(), metatableDTO.getUuid()); assertEquals(metatableEntity.getLastUpdateTimestamp(), metatableDTO.getLastUpdateTimestamp()); MetafileDTO[] metafileDTOs = new MetafileDTO[metatableDTO.getMetafileSet().size()]; metatableDTO.getMetafileSet().toArray(metafileDTOs); MetafileEntity[] metafileEntities = new MetafileEntity[metatableEntity.getMetafileSet() .size()]; metatableEntity.getMetafileSet().toArray(metafileEntities); assertEquals(metafileDTOs.length, metafileEntities.length); int countEquals = compareMetafileDTOAndEntitySet(metatableDTO.getMetafileSet(), metatableEntity.getMetafileSet()); assertEquals(countEquals, metafileDTOs.length); }