ViewDataMigrationContextImpl implements ViewDataMigrationContext { @Override public void copyAllInstanceData() { for (Map.Entry<String, Map<String, String>> userData : getOriginInstanceDataByUser().entrySet()) { for (Map.Entry<String, String> entry : userData.getValue().entrySet()) { putCurrentInstanceData(userData.getKey(), entry.getKey(), entry.getValue()); } } } 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();  }
@Test public void copyAllInstanceData() throws Exception { ViewEntity entity1 = getViewEntityMock(VERSION_1); ViewEntity entity2 = getViewEntityMock(VERSION_2); replay(entity1, entity2); ViewInstanceDataEntity dataEntity = new ViewInstanceDataEntity(); dataEntity.setName("name1"); dataEntity.setValue("value1"); dataEntity.setUser("user1"); Collection<ViewInstanceDataEntity> data1 = Arrays.asList(dataEntity); List<ViewInstanceDataEntity> data2 = new ArrayList<>(); ViewInstanceEntity instanceEntity1 = getViewInstanceEntityMock(entity1); expect(instanceEntity1.getData()).andReturn(data1).anyTimes(); ViewInstanceEntity instanceEntity2 = getViewInstanceEntityMock(entity2); expect(instanceEntity2.getData()).andReturn(data2).anyTimes(); replay(instanceEntity1, instanceEntity2); ViewDataMigrationContextImpl context = new TestViewDataMigrationContextImpl(instanceEntity1, instanceEntity2); context.copyAllInstanceData(); Assert.assertEquals(1, data2.size()); Assert.assertEquals("user1", data2.get(0).getUser()); Assert.assertEquals("name1", data2.get(0).getName()); Assert.assertEquals("value1", data2.get(0).getValue()); }