@Test public void copyAllObjects() throws Exception { ViewEntity entity1 = getViewEntityMock(VERSION_1); ViewEntity entity2 = getViewEntityMock(VERSION_2); replay(entity1, entity2); ViewInstanceEntity instanceEntity1 = getViewInstanceEntityMock(entity1); ViewInstanceEntity instanceEntity2 = getViewInstanceEntityMock(entity2); replay(instanceEntity1, instanceEntity2); TestViewDataMigrationContextImpl context = new TestViewDataMigrationContextImpl(instanceEntity1, instanceEntity2); DataStore dataStore1 = createStrictMock(DataStore.class); expect(dataStore1.findAll(eq(SampleEntity.class), (String) isNull())).andReturn( Arrays.asList(new SampleEntity("data1"), new SampleEntity("data2"))); replay(dataStore1); DataStore dataStore2 = createStrictMock(DataStore.class); Capture<SampleEntity> copiedEntity1 = Capture.newInstance(); Capture<SampleEntity> copiedEntity2 = Capture.newInstance(); dataStore2.store(capture(copiedEntity1)); expectLastCall(); dataStore2.store(capture(copiedEntity2)); expectLastCall(); replay(dataStore2); context.setMockOriginDataStore(dataStore1); context.setMockCurrentDataStore(dataStore2); context.copyAllObjects(SampleEntity.class, SampleEntity.class); verify(dataStore1); verify(dataStore2); Assert.assertEquals("data1", copiedEntity1.getValue().getField()); Assert.assertEquals("data2", copiedEntity2.getValue().getField()); }
@Override public void copyAllObjects(Class originEntityClass, Class currentEntityClass) throws ViewDataMigrationException { copyAllObjects(originEntityClass, currentEntityClass, new EntityConverter() { @Override public void convert(Object orig, Object dest) { BeanUtils.copyProperties(orig, dest); } }); }
ViewDataMigrationContextImpl implements ViewDataMigrationContext { @Override public void copyAllObjects(Class originEntityClass, Class currentEntityClass) throws ViewDataMigrationException { copyAllObjects(originEntityClass, currentEntityClass, new EntityConverter() { @Override public void convert(Object orig, Object dest) { BeanUtils.copyProperties(orig, dest); } }); } }
ViewDataMigrationContextImpl implements ViewDataMigrationContext { @Override public void copyAllObjects(Class originEntityClass, Class currentEntityClass) throws ViewDataMigrationException { copyAllObjects(originEntityClass, currentEntityClass, new EntityConverter() { @Override public void convert(Object orig, Object dest) { BeanUtils.copyProperties(orig, dest); } }); } ViewDataMigrationContextImpl(ViewInstanceEntity originInstanceDefinition,
                                      ViewInstanceEntity currentInstanceDefinition); }
ViewDataMigrationContextImpl implements ViewDataMigrationContext { @Override public void copyAllObjects(Class originEntityClass, Class currentEntityClass) throws ViewDataMigrationException { copyAllObjects(originEntityClass, currentEntityClass, new EntityConverter() { @Override public void convert(Object orig, Object dest) { BeanUtils.copyProperties(orig, dest); } }); } ViewDataMigrationContextImpl(ViewInstanceEntity originInstanceDefinition,
                                      ViewInstanceEntity currentInstanceDefinition); @Override int getCurrentDataVersion(); @Override int getOriginDataVersion(); @Override DataStore getOriginDataStore(); @Override DataStore getCurrentDataStore(); @Override @Transactional void putCurrentInstanceData(String user, String key, String value); @Override void copyAllObjects(Class originEntityClass, Class currentEntityClass); @Override @Transactional void copyAllObjects(Class originEntityClass, Class currentEntityClass, EntityConverter entityConverter); @Override void copyAllInstanceData(); @Override ViewInstanceEntity getOriginInstanceDefinition(); @Override Map<String, Class> getOriginEntityClasses(); @Override Map<String, Class> getCurrentEntityClasses(); @Override ViewInstanceEntity getCurrentInstanceDefinition(); @Override Map<String, Map<String, String>> getOriginInstanceDataByUser(); @Override @Transactional void putOriginInstanceData(String user, String key, String value); @Override Map<String, Map<String, String>> getCurrentInstanceDataByUser(); void closeMigration(); }
ViewDataMigrationContextImpl implements ViewDataMigrationContext { @Override public void copyAllObjects(Class originEntityClass, Class currentEntityClass) throws ViewDataMigrationException { copyAllObjects(originEntityClass, currentEntityClass, new EntityConverter() { @Override public void convert(Object orig, Object dest) { BeanUtils.copyProperties(orig, dest); } }); } ViewDataMigrationContextImpl(ViewInstanceEntity originInstanceDefinition,
                                      ViewInstanceEntity currentInstanceDefinition); @Override int getCurrentDataVersion(); @Override int getOriginDataVersion(); @Override DataStore getOriginDataStore(); @Override DataStore getCurrentDataStore(); @Override @Transactional void putCurrentInstanceData(String user, String key, String value); @Override void copyAllObjects(Class originEntityClass, Class currentEntityClass); @Override @Transactional void copyAllObjects(Class originEntityClass, Class currentEntityClass, EntityConverter entityConverter); @Override void copyAllInstanceData(); @Override ViewInstanceEntity getOriginInstanceDefinition(); @Override Map<String, Class> getOriginEntityClasses(); @Override Map<String, Class> getCurrentEntityClasses(); @Override ViewInstanceEntity getCurrentInstanceDefinition(); @Override Map<String, Map<String, String>> getOriginInstanceDataByUser(); @Override @Transactional void putOriginInstanceData(String user, String key, String value); @Override Map<String, Map<String, String>> getCurrentInstanceDataByUser(); void closeMigration();  }