NamedConfigurationDAOMysqlImpl extends AbstractTableCreatingDAOImpl implements NamedConfigurationDAO { public int deleteConfiguration(NamedConfiguration namedConfiguration) { Preconditions.checkNotNull(namedConfiguration); Preconditions.checkNotNull(namedConfiguration.getName()); Preconditions.checkNotNull(namedConfiguration.getPluginId()); Preconditions.checkNotNull(namedConfiguration.getPluginId().getUri()); Preconditions.checkNotNull(namedConfiguration.getPluginId().getVersion()); return deleteConfiguration.update(namedConfiguration.getTenantId(), namedConfiguration.getAssocTypeId(), namedConfiguration.getPluginId().getUri().toASCIIString(), namedConfiguration.getPluginId().getVersion().toString(), namedConfiguration.getName()); } NamedConfigurationDAOMysqlImpl(DataSource dataSource, SqlScriptService sqlScriptService,
                                          PluginRegistry pluginRegistry); @Override String getDefaultTableName(); @Override String getTableCreatingSQLScriptName(); int updateConfiguration(NamedConfiguration namedConfiguration); int createConfiguration(NamedConfiguration namedConfiguration); int deleteConfiguration(NamedConfiguration namedConfiguration); NamedConfiguration readConfiguration(int tenantId, int assocTypeId, PluginId pluginId, String name); List<NamedConfiguration> readConfigurations(int tenantId, int assocTypeId, PluginId pluginId); NamedConfiguration readActiveConfiguration(int tenantId, int assocTypeId); int deactivateByPlugin(PluginId pluginId); int deactivateByAssocType(Integer tenantId, Integer assocTypeId);  }
@Test @ExpectedDataSet("/dbunit/pluginContainer/plugin_configuration+deleted.xml") public void deleteConfiguration_shouldDeleteConfigurationsAndNotDeleteActiveConfigurations() { int rowsAffected; NamedConfiguration config; config = new NamedConfiguration(1, 1, waitingGenerator.getId(), "Configuration 2", null, false); rowsAffected = namedConfigurationDAO.deleteConfiguration(config); assertThat(rowsAffected, is(1)); config = new NamedConfiguration(1, 2, waitingGenerator.getId(), "Configuration 1", null, false); rowsAffected = namedConfigurationDAO.deleteConfiguration(config); assertThat(rowsAffected, is(0)); config = new NamedConfiguration(2, 1, waitingGenerator.getId(), "Configuration 1", null, false); rowsAffected = namedConfigurationDAO.deleteConfiguration(config); assertThat(rowsAffected, is(0)); config = new NamedConfiguration(3, 1, waitingGenerator.getId(), "Configuration 2", null, false); rowsAffected = namedConfigurationDAO.deleteConfiguration(config); assertThat(rowsAffected, is(0)); }
@Test(expected = NullPointerException.class) public void deleteConfiguration_shouldThrowOnNullNamedConfiguration() { namedConfigurationDAO.deleteConfiguration(null); }
@Test(expected = NullPointerException.class) public void deleteConfiguration_shouldThrowOnNullPluginId() { NamedConfiguration config = new NamedConfiguration(1, 1, null, "Configuration 2", null, false); namedConfigurationDAO.deleteConfiguration(config); }
@Test(expected = NullPointerException.class) public void deleteConfiguration_shouldThrowOnNullPluginName() { NamedConfiguration config = new NamedConfiguration(1, 1, waitingGenerator.getId(), null, null, false); namedConfigurationDAO.deleteConfiguration(config); }