JdbcParamRepository implements WritableParamRepository, EditableParamRepository, ViewableParamRepository, InitializableComponent { @Override public void write(final Parameter parameter) { transactionRunner.run(new VoidTransactionWrapper() { @Override public void performVoid(QueryRunner queryRunner) { write(queryRunner, parameter); } }); } JdbcParamRepository(TransactionRunner operationRunner, JdbcParameterEntryBatchLoaderFactory batchLoaderFactory,
            JdbcRepository dao, SchemaCreator schemaCreator); @Override void initialize(); @Override RepositoryCapabilities capabilities(); @Override Set<String> listParameters(); @Override List<String> listParameters(ParameterFilter filter); @Override Parameter load(final String parameterName); @Override ParameterBatchLoader batchLoad(final String parameterName); @Override Set<ParameterEntry> findEntries(String parameterName, String[] levelValues); @Override void write(final Parameter parameter); @Override void write(final ParameterBatchLoader batchLoader); @Override void writeAll(final Iterable<Parameter> parameters); @Override void writeParameterEntries(final String parameterName, final Iterable<ParameterEntry> parameterEntries); @Override void delete(final String parameterName); @Override Parameter getParameterMetadata(final String prameterName); @Override ParameterKey createParameter(final Parameter parameter); @Override void updateParameter(final String parameterName, final Parameter parameter); @Override void deleteParameter(String parameterName); @Override LevelKey addLevel(final String parameterName, final Level level); @Override void updateLevel(String parameterName, final LevelKey levelKey, final Level level); @Override void reorderLevels(String parameterName, final List<LevelKey> orderedLevels); @Override void deleteLevel(final String parameterName, final LevelKey levelKey); @Override List<ParameterEntry> getParameterEntries(final String parameterName, final Iterable<ParameterEntryKey> parameterEntryKeys); @Override List<ParameterEntry> listEntries(final String parameterName, final ParameterEntriesFilter filter); @Override ParameterEntryKey addEntry(final String parameterName, final ParameterEntry entry); @Override List<ParameterEntryKey> addEntries(final String parameterName, final Iterable<ParameterEntry> entries); @Override void updateEntry(String parameterName, final ParameterEntryKey entryKey, final ParameterEntry entry); @Override void deleteEntry(String parameterName, final ParameterEntryKey entryKey); @Override void deleteEntries(String parameterName, final Iterable<ParameterEntryKey> entryKeys); @Override void deleteEntries(final String parameterName);  }
@Test public void shouldWriteNewParameterIntoDatabase() { Level[] levels = new Level[]{level().withName("lvl1").withType("string").build()}; ParameterEntry[] entries = new ParameterEntry[]{parameterEntry().withLevels("A").build()}; Parameter parameter = parameter().withName("parameter").withLevels(levels).withEntries(entries).build(); JdbcParamRepository repository = get(JdbcParamRepository.class); repository.write(parameter); assertDatabase().hasParameter("parameter").hasEntriesForParameter("parameter", 1).hasLevelsForParameter("parameter", 1).close(); }
@Test public void shouldOverwriteExistingParameterWithSameName() { database().withParameter("parameter").withLevels("parameter", 2).withParameterEntries("parameter", 2).build(); Level[] levels = new Level[]{level().withName("lvl1").withType("string").build()}; ParameterEntry[] entries = new ParameterEntry[]{parameterEntry().withLevels("A").build()}; Parameter parameter = parameter().withName("parameter").withLevels(levels).withEntries(entries).build(); JdbcParamRepository repository = get(JdbcParamRepository.class); repository.write(parameter); assertDatabase().hasParameter("parameter").hasEntriesForParameter("parameter", 1).hasLevelsForParameter("parameter", 1).close(); }