@Test void testCopy() { EntityType entityType = mock(EntityType.class); EntityType entityTypeMeta = mockEntityTypeMetadata(); when(entityType.getEntityType()).thenReturn(entityTypeMeta); Attribute idAttr = mock(Attribute.class); when(idAttr.getIdentifier()).thenReturn("id"); when(idAttr.getName()).thenReturn("id"); Attribute idAttrCopy = mock(Attribute.class); when(idAttrCopy.getName()).thenReturn("id"); when(idAttrCopy.setEntity(any())).thenReturn(idAttrCopy); when(entityType.getOwnAllAttributes()).thenReturn(singletonList(idAttr)); when(attributeFactory.create()).thenReturn(idAttrCopy); CopyState state = CopyState.create(null, mock(Progress.class)); copier.copy(entityType, state); assertEquals(of("id", idAttrCopy), state.copiedAttributes()); }
public EntityType copy(EntityType entityType, CopyState state) { EntityType copy = EntityType.newInstance(entityType, SHALLOW_COPY_ATTRS, attributeFactory); Map<String, Attribute> copiedAttributes = EntityType.deepCopyAttributes(entityType, copy, attributeFactory); state.copiedAttributes().putAll(copiedAttributes); return copy; }
EntityTypeMetadataCopier { public EntityType copy(EntityType entityType, CopyState state) { EntityType copy = EntityType.newInstance(entityType, SHALLOW_COPY_ATTRS, attributeFactory); Map<String, Attribute> copiedAttributes = EntityType.deepCopyAttributes(entityType, copy, attributeFactory); state.copiedAttributes().putAll(copiedAttributes); return copy; } }
EntityTypeMetadataCopier { public EntityType copy(EntityType entityType, CopyState state) { EntityType copy = EntityType.newInstance(entityType, SHALLOW_COPY_ATTRS, attributeFactory); Map<String, Attribute> copiedAttributes = EntityType.deepCopyAttributes(entityType, copy, attributeFactory); state.copiedAttributes().putAll(copiedAttributes); return copy; } EntityTypeMetadataCopier(AttributeFactory attributeFactory); }
EntityTypeMetadataCopier { public EntityType copy(EntityType entityType, CopyState state) { EntityType copy = EntityType.newInstance(entityType, SHALLOW_COPY_ATTRS, attributeFactory); Map<String, Attribute> copiedAttributes = EntityType.deepCopyAttributes(entityType, copy, attributeFactory); state.copiedAttributes().putAll(copiedAttributes); return copy; } EntityTypeMetadataCopier(AttributeFactory attributeFactory); EntityType copy(EntityType entityType, CopyState state); }
EntityTypeMetadataCopier { public EntityType copy(EntityType entityType, CopyState state) { EntityType copy = EntityType.newInstance(entityType, SHALLOW_COPY_ATTRS, attributeFactory); Map<String, Attribute> copiedAttributes = EntityType.deepCopyAttributes(entityType, copy, attributeFactory); state.copiedAttributes().putAll(copiedAttributes); return copy; } EntityTypeMetadataCopier(AttributeFactory attributeFactory); EntityType copy(EntityType entityType, CopyState state);  }