NamedConfigurationDAOMysqlImpl extends AbstractTableCreatingDAOImpl implements NamedConfigurationDAO { public NamedConfiguration readConfiguration(int tenantId, int assocTypeId, PluginId pluginId, String name) { Preconditions.checkNotNull(pluginId); Preconditions.checkNotNull(pluginId.getUri()); Preconditions.checkNotNull(pluginId.getVersion()); Preconditions.checkNotNull(name); return readConfiguration.findObject(tenantId, assocTypeId, pluginId.getUri().toASCIIString(), pluginId.getVersion().toString(), name); } 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 @DataSet("/dbunit/pluginContainer/plugin_configuration+erronous_name_config.xml") public void readConfiguration_shouldReturnUnmarshalFailedConfiguration() { NamedConfiguration config; config = namedConfigurationDAO.readConfiguration(1, 1, waitingGenerator.getId(), "Configuration 1"); assertThat(config, is(not(nullValue()))); assertThat(config.getName(), is("Configuration 1")); assertThat(config.getConfiguration(), is(GeneratorConfigurationConstants.CONF_UNMARSHAL_FAILED)); config = namedConfigurationDAO.readConfiguration(1, 1, waitingGenerator.getId(), "XXXX"); }
@Test public void readConfiguration_getsConfigurationOrNull() { NamedConfiguration config; config = namedConfigurationDAO.readConfiguration(1, 1, waitingGenerator.getId(), "Configuration 1"); assertThat(config, is(not(nullValue()))); assertThat(config.getName(), is("Configuration 1")); assertThat(config.getConfiguration().getAssociationType(), is("1-1-1")); config = namedConfigurationDAO.readConfiguration(1, 1, waitingGenerator.getId(), "Configuration 2"); assertThat(config, is(not(nullValue()))); assertThat(config.getName(), is("Configuration 2")); assertThat(config.getConfiguration().getAssociationType(), is("1-1-2")); config = namedConfigurationDAO.readConfiguration(1, 1, waitingGenerator.getId(), "Configuration 3"); assertThat(config, is(nullValue())); config = namedConfigurationDAO.readConfiguration(1, 2, waitingGenerator.getId(), "Configuration 1"); assertThat(config, is(not(nullValue()))); assertThat(config.getName(), is("Configuration 1")); assertThat(config.getConfiguration().getAssociationType(), is("1-2-1")); config = namedConfigurationDAO.readConfiguration(2, 1, waitingGenerator.getId(), "Configuration 1"); assertThat(config, is(not(nullValue()))); assertThat(config.getName(), is("Configuration 1")); assertThat(config.getConfiguration().getAssociationType(), is("2-1-1")); }
@Test(expected = NullPointerException.class) public void readConfiguration_shouldThrowOnNullPluginId() { namedConfigurationDAO.readConfiguration(1, 1, null, "Configuration 1"); }
@Test(expected = NullPointerException.class) public void readConfiguration_shouldThrowOnNullName() { namedConfigurationDAO.readConfiguration(1, 1, waitingGenerator.getId(), null); }