@Test void copyDoubleEntityType() { setupPredictableIdGeneratorMock(idGenerator); EntityType entityTypeA = mock(EntityType.class); when(entityTypeA.getId()).thenReturn("A"); EntityType entityTypeACopy = mock(EntityType.class); Package targetPackage = mock(Package.class); Progress progress = mock(Progress.class); CopyState state = CopyState.create(targetPackage, progress); setupMetadataCopierAnswers(ImmutableMap.of(entityTypeA, entityTypeACopy)); when(entityTypeDependencyResolver.resolve(singletonList(entityTypeACopy))) .thenReturn(singletonList(entityTypeACopy)); state.entityTypesInPackages().add(entityTypeA); copier.copy(singletonList(entityTypeA), state); verify(entityTypeACopy).setId("id1"); assertEquals(of("A", entityTypeACopy), state.copiedEntityTypes()); assertEquals(of("id1", "A"), state.originalEntityTypeIds()); assertEquals(emptyMap(), state.referenceDefaultValues()); verify(dataService.getMeta()).addEntityType(entityTypeACopy); verify(progress, times(1)).increment(1); }
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);  }