use of com.quorum.tessera.key.generation.KeyGeneratorFactory in project tessera by ConsenSys.
the class KeyGenCommandTest method beforeTest.
@Before
public void beforeTest() {
keyGeneratorFactory = mock(KeyGeneratorFactory.class);
configFileUpdaterWriter = mock(ConfigFileUpdaterWriter.class);
passwordFileUpdaterWriter = mock(PasswordFileUpdaterWriter.class);
keyDataMarshaller = mock(KeyDataMarshaller.class);
keyGenCommand = new KeyGenCommand(keyGeneratorFactory, configFileUpdaterWriter, passwordFileUpdaterWriter, keyDataMarshaller);
keyGenerator = mock(KeyGenerator.class);
executionExceptionHandler = new CliExecutionExceptionHandler();
parameterExceptionHandler = mock(CLIExceptionCapturer.class);
commandLine = new CommandLine(keyGenCommand);
commandLine.setExecutionExceptionHandler(executionExceptionHandler);
commandLine.setParameterExceptionHandler(parameterExceptionHandler);
}
use of com.quorum.tessera.key.generation.KeyGeneratorFactory in project tessera by ConsenSys.
the class KeyGenCommandFactory method create.
@Override
public <K> K create(Class<K> cls) throws Exception {
try {
if (cls != KeyGenCommand.class) {
throw new RuntimeException(this.getClass().getSimpleName() + " cannot create instance of type " + cls.getSimpleName());
}
KeyGeneratorFactory keyGeneratorFactory = KeyGeneratorFactory.create();
ConfigFileUpdaterWriter configFileUpdaterWriter = new ConfigFileUpdaterWriter(FilesDelegate.create());
PasswordFileUpdaterWriter passwordFileUpdaterWriter = new PasswordFileUpdaterWriter(FilesDelegate.create());
KeyDataMarshaller keyDataMarshaller = KeyDataMarshaller.create();
return (K) new KeyGenCommand(keyGeneratorFactory, configFileUpdaterWriter, passwordFileUpdaterWriter, keyDataMarshaller);
} catch (Exception e) {
// fallback if missing
return CommandLine.defaultFactory().create(cls);
}
}
Aggregations