@Test void testUpsert() { Attribute targetAttribute = attrMetaFactory.create().setName("targetAttribute"); List<Attribute> sourceAttributes = Lists.newArrayList(); EntityType sourceEntityType = entityTypeFactory.create("source"); EntityType targetEntityType = entityTypeFactory.create("target"); targetEntityType.addAttribute(targetAttribute); List<AttributeMapping> attributeMappings = Lists.newArrayList(); attributeMappings.add( new AttributeMapping( "1", "targetAttribute", targetAttribute, "algorithm", sourceAttributes, CURATED.toString())); Collection<EntityMapping> entityMappings = singletonList( new EntityMapping(AUTO_ID, sourceEntityType, targetEntityType, attributeMappings)); Entity attributeMappingEntity = new DynamicEntity(attrMappingMeta); attributeMappingEntity.set(EntityMappingMetadata.IDENTIFIER, AUTO_ID); attributeMappingEntity.set(AttributeMappingMetadata.TARGET_ATTRIBUTE, "targetAttribute"); attributeMappingEntity.set(AttributeMappingMetadata.SOURCE_ATTRIBUTES, ""); attributeMappingEntity.set(AttributeMappingMetadata.ALGORITHM, "algorithm"); attributeMappingEntity.set(AttributeMappingMetadata.ALGORITHM_STATE, CURATED.toString()); List<Entity> attributeMappingEntities = Lists.newArrayList(); attributeMappingEntities.add(attributeMappingEntity); List<Entity> entityMappingEntities = Lists.newArrayList(); Entity entityMappingEntity = new DynamicEntity(entityMappingMeta); entityMappingEntity.set(EntityMappingMetadata.IDENTIFIER, AUTO_ID); entityMappingEntity.set(EntityMappingMetadata.SOURCE_ENTITY_TYPE, "source"); entityMappingEntity.set(EntityMappingMetadata.TARGET_ENTITY_TYPE, "target"); entityMappingEntity.set(EntityMappingMetadata.ATTRIBUTE_MAPPINGS, attributeMappingEntities); entityMappingEntities.add(entityMappingEntity); assertTrue( EntityUtils.equals( entityMappingRepository.upsert(entityMappings).get(0), entityMappingEntities.get(0))); }
@Override public List<Entity> upsert(Collection<EntityMapping> entityMappings) { return entityMappings.stream().map(this::upsert).collect(Collectors.toList()); }
EntityMappingRepositoryImpl implements EntityMappingRepository { @Override public List<Entity> upsert(Collection<EntityMapping> entityMappings) { return entityMappings.stream().map(this::upsert).collect(Collectors.toList()); } }
EntityMappingRepositoryImpl implements EntityMappingRepository { @Override public List<Entity> upsert(Collection<EntityMapping> entityMappings) { return entityMappings.stream().map(this::upsert).collect(Collectors.toList()); } EntityMappingRepositoryImpl(AttributeMappingRepository attributeMappingRepository); }
EntityMappingRepositoryImpl implements EntityMappingRepository { @Override public List<Entity> upsert(Collection<EntityMapping> entityMappings) { return entityMappings.stream().map(this::upsert).collect(Collectors.toList()); } EntityMappingRepositoryImpl(AttributeMappingRepository attributeMappingRepository); @Override List<EntityMapping> toEntityMappings(List<Entity> entityMappingEntities); @Override List<Entity> upsert(Collection<EntityMapping> entityMappings); }
EntityMappingRepositoryImpl implements EntityMappingRepository { @Override public List<Entity> upsert(Collection<EntityMapping> entityMappings) { return entityMappings.stream().map(this::upsert).collect(Collectors.toList()); } EntityMappingRepositoryImpl(AttributeMappingRepository attributeMappingRepository); @Override List<EntityMapping> toEntityMappings(List<Entity> entityMappingEntities); @Override List<Entity> upsert(Collection<EntityMapping> entityMappings);  }