use of com.quorum.tessera.cli.CliResult in project tessera by ConsenSys.
the class KeyGenCommandTest method onlyConfigWithKeysProvided.
@Test
public void onlyConfigWithKeysProvided() throws Exception {
// given
when(keyGeneratorFactory.create(eq(null), any(EncryptorConfig.class))).thenReturn(keyGenerator);
CommandLine commandLine = new CommandLine(keyGenCommand);
Config config = mock(Config.class);
KeyConfiguration keyConfiguration = mock(KeyConfiguration.class);
when(config.getKeys()).thenReturn(keyConfiguration);
CommandLine.ITypeConverter<Config> configConverter = mock(CommandLine.ITypeConverter.class);
when(configConverter.convert("myconfig.file")).thenReturn(config);
commandLine.registerConverter(Config.class, configConverter);
int exceptionExitCode = 999;
List<Exception> exceptions = new ArrayList<>();
commandLine.setExecutionExceptionHandler((ex, cmd, parseResult) -> {
exceptions.add(ex);
return exceptionExitCode;
});
int exitCode = commandLine.execute("--configfile=myconfig.file");
assertThat(exitCode).isZero();
assertThat(exceptions).isEmpty();
verify(configConverter).convert("myconfig.file");
CliResult result = commandLine.getExecutionResult();
assertThat(result).isNotNull();
assertThat(result.isSuppressStartup()).isTrue();
assertThat(result.getStatus()).isZero();
verifyNoMoreInteractions(configConverter);
verify(keyGeneratorFactory).create(eq(null), any(EncryptorConfig.class));
verify(configFileUpdaterWriter).updateAndWriteToCLI(anyList(), eq(null), any(Config.class));
verify(keyDataMarshaller).marshal(null);
verify(keyGenerator).generate("", null, null);
}
use of com.quorum.tessera.cli.CliResult in project tessera by ConsenSys.
the class VersionCommandTest method call.
@Test
public void call() {
VersionCommand cmd = new VersionCommand();
CliResult result = cmd.call();
CliResult want = new CliResult(0, true, null);
assertThat(result).isEqualToComparingFieldByField(want);
}
use of com.quorum.tessera.cli.CliResult in project tessera by ConsenSys.
the class MigrationCliAdapter method execute.
@Override
public CliResult execute(String... args) {
EntityManagerFactory primaryEntityManagerFactory = JdbcConfigUtil.entityManagerFactory(configPrimary.getJdbcConfig());
EntityManagerFactory secondaryEntityManagerFactory = JdbcConfigUtil.entityManagerFactory(configSecondary.getJdbcConfig());
// migrate raw
new MigrationRunner(primaryEntityManagerFactory, secondaryEntityManagerFactory).run();
return new CliResult(0, true, null);
}
Aggregations