public boolean validateTree(ValidationContext validationContext) { validate(validationContext); boolean isValid = errors.isEmpty(); ValidationContext contextForChildren = validationContext.withParent(this); isValid = tasks.validateTree(contextForChildren) && isValid; isValid = variables.validateTree(contextForChildren) && isValid; isValid = resourceConfigs.validateTree(contextForChildren) && isValid; isValid = artifactPropertiesConfig.validateTree(contextForChildren) && isValid; isValid = tabs.validateTree(contextForChildren) && isValid; isValid = artifactConfigs.validateTree(contextForChildren) && isValid; return isValid; }
when(resourceConfigs.validateTree(any(PipelineConfigSaveValidationContext.class))).thenReturn(false); when(properties.validateTree(any(PipelineConfigSaveValidationContext.class))).thenReturn(false); when(artifactConfigs.validateTree(any(PipelineConfigSaveValidationContext.class))).thenReturn(false); when(tabs.validateTree(any(PipelineConfigSaveValidationContext.class))).thenReturn(false); when(variables.validateTree(any(PipelineConfigSaveValidationContext.class))).thenReturn(false); verify(resourceConfigs).validateTree(childContext); verify(properties).validateTree(childContext); verify(artifactConfigs).validateTree(childContext); verify(tabs).validateTree(childContext); verify(variables).validateTree(childContext);
when(resourceConfigs.validateTree(any(PipelineConfigSaveValidationContext.class))).thenReturn(true); when(properties.validateTree(any(PipelineConfigSaveValidationContext.class))).thenReturn(true); when(artifactConfigs.validateTree(any(PipelineConfigSaveValidationContext.class))).thenReturn(true); when(tabs.validateTree(any(PipelineConfigSaveValidationContext.class))).thenReturn(true); when(variables.validateTree(any(PipelineConfigSaveValidationContext.class))).thenReturn(true); verify(resourceConfigs).validateTree(childContext); verify(properties).validateTree(childContext); verify(artifactConfigs).validateTree(childContext); verify(tabs).validateTree(childContext); verify(variables).validateTree(childContext);
@Test public void shouldValidateTree() { ArtifactConfigs artifactConfigs = new ArtifactConfigs(); artifactConfigs.add(new BuildArtifactConfig("src", "dest")); artifactConfigs.add(new BuildArtifactConfig("src", "dest")); artifactConfigs.add(new BuildArtifactConfig("src", "../a")); artifactConfigs.validateTree(null); assertThat(artifactConfigs.get(0).errors().on(BuiltinArtifactConfig.DEST), is("Duplicate artifacts defined.")); assertThat(artifactConfigs.get(0).errors().on(BuiltinArtifactConfig.SRC), is("Duplicate artifacts defined.")); assertThat(artifactConfigs.get(1).errors().on(BuiltinArtifactConfig.DEST), is("Duplicate artifacts defined.")); assertThat(artifactConfigs.get(1).errors().on(BuiltinArtifactConfig.SRC), is("Duplicate artifacts defined.")); assertThat(artifactConfigs.get(2).errors().on(BuiltinArtifactConfig.DEST), is("Invalid destination path. Destination path should match the pattern " + FilePathTypeValidator.PATH_PATTERN)); }