@Test void copyWithDefaultReferenceValue() { setupPredictableIdGeneratorMock(idGenerator); EntityType entityType = mockEntityType("A"); EntityType entityTypeCopy = mock(EntityType.class); Attribute refAttrCopy = mock(Attribute.class); when(entityTypeCopy.getAtomicAttributes()).thenReturn(singletonList(refAttrCopy)); when(refAttrCopy.getIdentifier()).thenReturn("refAttr"); when(refAttrCopy.getDataType()).thenReturn(AttributeType.MREF); when(refAttrCopy.hasDefaultValue()).thenReturn(true); when(refAttrCopy.getDefaultValue()).thenReturn("row1,row2,row3"); Package targetPackage = mock(Package.class); Progress progress = mock(Progress.class); CopyState state = CopyState.create(targetPackage, progress); when(entityTypeMetadataCopier.copy(entityType, state)).thenReturn(entityTypeCopy); when(entityTypeDependencyResolver.resolve(singletonList(entityTypeCopy))) .thenReturn(singletonList(entityTypeCopy)); copier.copy(singletonList(entityType), state); assertEquals(of("refAttr", "row1,row2,row3"), state.referenceDefaultValues()); verify(refAttrCopy).setDefaultValue("row1,row2,row3"); }
public void copy(List<EntityType> entityTypes, CopyState state) { List<EntityType> preparedEntityTypes = prepareEntityTypes(entityTypes, state); List<EntityType> copiedEntityTypes = copyEntityTypes(preparedEntityTypes, state); persist(copiedEntityTypes, state); }
EntityTypeCopier { public void copy(List<EntityType> entityTypes, CopyState state) { List<EntityType> preparedEntityTypes = prepareEntityTypes(entityTypes, state); List<EntityType> copiedEntityTypes = copyEntityTypes(preparedEntityTypes, state); persist(copiedEntityTypes, state); } }
EntityTypeCopier { public void copy(List<EntityType> entityTypes, CopyState state) { List<EntityType> preparedEntityTypes = prepareEntityTypes(entityTypes, state); List<EntityType> copiedEntityTypes = copyEntityTypes(preparedEntityTypes, state); persist(copiedEntityTypes, state); } EntityTypeCopier(
      DataService dataService,
      IdGenerator idGenerator,
      EntityTypeDependencyResolver entityTypeDependencyResolver,
      EntityTypeMetadataCopier entityTypeMetadataCopier); }
EntityTypeCopier { public void copy(List<EntityType> entityTypes, CopyState state) { List<EntityType> preparedEntityTypes = prepareEntityTypes(entityTypes, state); List<EntityType> copiedEntityTypes = copyEntityTypes(preparedEntityTypes, state); persist(copiedEntityTypes, state); } EntityTypeCopier(
      DataService dataService,
      IdGenerator idGenerator,
      EntityTypeDependencyResolver entityTypeDependencyResolver,
      EntityTypeMetadataCopier entityTypeMetadataCopier); void copy(List<EntityType> entityTypes, CopyState state); }
EntityTypeCopier { public void copy(List<EntityType> entityTypes, CopyState state) { List<EntityType> preparedEntityTypes = prepareEntityTypes(entityTypes, state); List<EntityType> copiedEntityTypes = copyEntityTypes(preparedEntityTypes, state); persist(copiedEntityTypes, state); } EntityTypeCopier(
      DataService dataService,
      IdGenerator idGenerator,
      EntityTypeDependencyResolver entityTypeDependencyResolver,
      EntityTypeMetadataCopier entityTypeMetadataCopier); void copy(List<EntityType> entityTypes, CopyState state);  }