@Test public void testNewDataMapImport() throws Exception { DbImportConfiguration config = mock(DbImportConfiguration.class); when(config.createMergeDelegate()).thenReturn(new DefaultModelMergeDelegate()); when(config.getDbLoaderConfig()).thenReturn(new DbLoaderConfiguration()); when(config.getTargetDataMap()).thenReturn(new File("xyz.map.xml")); when(config.createNameGenerator()).thenReturn(new DefaultObjectNameGenerator(NoStemStemmer.getInstance())); when(config.createMeaningfulPKFilter()).thenReturn(NamePatternMatcher.EXCLUDE_ALL); DbLoader dbLoader = new DbLoader(mockAdapter, mockConnection, config.getDbLoaderConfig(), mockDelegate, mockNameGenerator) { @Override public DataMap load() throws SQLException { DataMap map = new DataMap(); new DataMapBuilder(map).withDbEntities(2).build(); return map; } }; final boolean[] haveWeTriedToSave = {false}; DefaultDbImportAction action = buildDbImportAction(new FileProjectSaver(Collections.emptyList()) { @Override public void save(Project project) { haveWeTriedToSave[0] = true; assertTrue(project.getRootNode() instanceof DataMap); } }, null, dbLoader); action.execute(config); assertTrue("We should try to save.", haveWeTriedToSave[0]); }
@Override public void execute(DbImportConfiguration config) throws Exception { commit(config, loadDataMap(config)); }
DefaultDbImportAction implements DbImportAction { @Override public void execute(DbImportConfiguration config) throws Exception { commit(config, loadDataMap(config)); } }
DefaultDbImportAction implements DbImportAction { @Override public void execute(DbImportConfiguration config) throws Exception { commit(config, loadDataMap(config)); } DefaultDbImportAction(@Inject Logger logger,
                                 @Inject ProjectSaver projectSaver,
                                 @Inject DataSourceFactory dataSourceFactory,
                                 @Inject DbAdapterFactory adapterFactory,
                                 @Inject DataMapLoader mapLoader,
                                 @Inject MergerTokenFactoryProvider mergerTokenFactoryProvider,
                                 @Inject DataChannelDescriptorLoader dataChannelDescriptorLoader,
                                 @Inject DataChannelMetaData metaData); }
DefaultDbImportAction implements DbImportAction { @Override public void execute(DbImportConfiguration config) throws Exception { commit(config, loadDataMap(config)); } DefaultDbImportAction(@Inject Logger logger,
                                 @Inject ProjectSaver projectSaver,
                                 @Inject DataSourceFactory dataSourceFactory,
                                 @Inject DbAdapterFactory adapterFactory,
                                 @Inject DataMapLoader mapLoader,
                                 @Inject MergerTokenFactoryProvider mergerTokenFactoryProvider,
                                 @Inject DataChannelDescriptorLoader dataChannelDescriptorLoader,
                                 @Inject DataChannelMetaData metaData); static void flattenManyToManyRelationships(DataMap map, Collection<ObjEntity> loadedObjEntities,
                                                         ObjectNameGenerator objectNameGenerator); @Override void execute(DbImportConfiguration config); boolean hasTokensToImport(Collection<MergerToken> tokens); }
DefaultDbImportAction implements DbImportAction { @Override public void execute(DbImportConfiguration config) throws Exception { commit(config, loadDataMap(config)); } DefaultDbImportAction(@Inject Logger logger,
                                 @Inject ProjectSaver projectSaver,
                                 @Inject DataSourceFactory dataSourceFactory,
                                 @Inject DbAdapterFactory adapterFactory,
                                 @Inject DataMapLoader mapLoader,
                                 @Inject MergerTokenFactoryProvider mergerTokenFactoryProvider,
                                 @Inject DataChannelDescriptorLoader dataChannelDescriptorLoader,
                                 @Inject DataChannelMetaData metaData); static void flattenManyToManyRelationships(DataMap map, Collection<ObjEntity> loadedObjEntities,
                                                         ObjectNameGenerator objectNameGenerator); @Override void execute(DbImportConfiguration config); boolean hasTokensToImport(Collection<MergerToken> tokens);  }