@Test public void shouldNotConsiderErrorsForEqualsCheck() { EnvironmentVariableConfig config1 = new EnvironmentVariableConfig("name", "value"); EnvironmentVariableConfig config2 = new EnvironmentVariableConfig("name", "value"); config2.addError("name", "errrr"); assertThat(config1.equals(config2), is(true)); }
public void deserialize(String name, String value, boolean isSecure, String encryptedValue) throws CryptoException { setName(name); setIsSecure(isSecure); if (!isSecure && encryptedValue != null) { errors().add(ENCRYPTEDVALUE, "You may specify encrypted value only when option 'secure' is true."); } if (value != null && encryptedValue != null) { addError("value", "You may only specify `value` or `encrypted_value`, not both!"); addError(ENCRYPTEDVALUE, "You may only specify `value` or `encrypted_value`, not both!"); } if (encryptedValue != null) { setEncryptedValue(goCipher.maybeReEncryptForPostConstructWithoutExceptions(encryptedValue)); } if (isSecure) { if (value != null) { setEncryptedValue(new EncryptedVariableValueConfig(new GoCipher().encrypt(value))); } } else { setValue(new VariableValueConfig(value)); } }
@Test public void shouldCopyErrorsForFieldsOnPipelineConfig(){ PipelineConfig pipelineConfig = PipelineConfigMother.pipelineConfig("pipeline", MaterialConfigsMother.defaultMaterialConfigs(), new JobConfigs(JobConfigMother.createJobConfigWithJobNameAndEmptyResources())); pipelineConfig.setVariables(new EnvironmentVariablesConfig(asList(new EnvironmentVariableConfig("name", "value")))); PipelineConfig pipelineWithErrors = new Cloner().deepClone(pipelineConfig); pipelineWithErrors.getVariables().get(0).addError("name", "error on environment variable"); pipelineWithErrors.first().addError("name", "error on stage"); pipelineWithErrors.first().getJobs().first().addError("name", "error on job"); BasicCruiseConfig.copyErrors(pipelineWithErrors, pipelineConfig); assertThat(pipelineConfig.getVariables().get(0).errors().on("name"), is("error on environment variable")); assertThat(pipelineConfig.first().errors().on("name"), is("error on stage")); assertThat(pipelineConfig.first().getJobs().first().errors().on("name"), is("error on job")); }