Search in sources :

Example 6 with CustomFieldDocument

use of com.synopsys.integration.detect.workflow.blackduck.project.customfields.CustomFieldDocument in project synopsys-detect by blackducksoftware.

the class DetectCustomFieldParserTest method parsedVersionMultiple.

@Test
public void parsedVersionMultiple() throws DetectUserFriendlyException {
    Map<String, String> props = new HashMap<>();
    props.put("detect.custom.fields.version[0].label", "label");
    props.put("detect.custom.fields.version[0].value", "value1");
    props.put("detect.custom.fields.version[1].label", "label");
    props.put("detect.custom.fields.version[1].value", "value1");
    props.put("detect.custom.fields.version[2].label", "label");
    props.put("detect.custom.fields.version[2].value", "value1");
    DetectCustomFieldParser parser = new DetectCustomFieldParser();
    CustomFieldDocument document = parser.parseCustomFieldDocument(props);
    Assertions.assertEquals(3, document.getVersion().size());
}
Also used : CustomFieldDocument(com.synopsys.integration.detect.workflow.blackduck.project.customfields.CustomFieldDocument) HashMap(java.util.HashMap) Test(org.junit.jupiter.api.Test)

Example 7 with CustomFieldDocument

use of com.synopsys.integration.detect.workflow.blackduck.project.customfields.CustomFieldDocument in project synopsys-detect by blackducksoftware.

the class DetectCustomFieldParserTest method parsedEmptySingleQuotesAsEmptyArray.

@Test
public void parsedEmptySingleQuotesAsEmptyArray() throws DetectUserFriendlyException {
    Map<String, String> props = new HashMap<>();
    props.put("detect.custom.fields.project[0].name", "example");
    props.put("detect.custom.fields.project[0].value", "''");
    DetectCustomFieldParser parser = new DetectCustomFieldParser();
    CustomFieldDocument document = parser.parseCustomFieldDocument(props);
    CustomFieldElement element = document.getProject().get(0);
    Assertions.assertEquals(0, element.getValue().size());
}
Also used : CustomFieldDocument(com.synopsys.integration.detect.workflow.blackduck.project.customfields.CustomFieldDocument) CustomFieldElement(com.synopsys.integration.detect.workflow.blackduck.project.customfields.CustomFieldElement) HashMap(java.util.HashMap) Test(org.junit.jupiter.api.Test)

Example 8 with CustomFieldDocument

use of com.synopsys.integration.detect.workflow.blackduck.project.customfields.CustomFieldDocument in project synopsys-detect by blackducksoftware.

the class DetectCustomFieldParserTest method parsedEmptyStringAsEmptyArray.

@Test
public void parsedEmptyStringAsEmptyArray() throws DetectUserFriendlyException {
    Map<String, String> props = new HashMap<>();
    props.put("detect.custom.fields.project[0].name", "example");
    props.put("detect.custom.fields.project[0].value", "");
    DetectCustomFieldParser parser = new DetectCustomFieldParser();
    CustomFieldDocument document = parser.parseCustomFieldDocument(props);
    CustomFieldElement element = document.getProject().get(0);
    Assertions.assertEquals(0, element.getValue().size());
}
Also used : CustomFieldDocument(com.synopsys.integration.detect.workflow.blackduck.project.customfields.CustomFieldDocument) CustomFieldElement(com.synopsys.integration.detect.workflow.blackduck.project.customfields.CustomFieldElement) HashMap(java.util.HashMap) Test(org.junit.jupiter.api.Test)

Example 9 with CustomFieldDocument

use of com.synopsys.integration.detect.workflow.blackduck.project.customfields.CustomFieldDocument in project synopsys-detect by blackducksoftware.

the class DetectCustomFieldParserTest method parsedEmptyQuotesAsEmptyArray.

@Test
public void parsedEmptyQuotesAsEmptyArray() throws DetectUserFriendlyException {
    Map<String, String> props = new HashMap<>();
    props.put("detect.custom.fields.project[0].name", "example");
    props.put("detect.custom.fields.project[0].value", "\"\"");
    DetectCustomFieldParser parser = new DetectCustomFieldParser();
    CustomFieldDocument document = parser.parseCustomFieldDocument(props);
    CustomFieldElement element = document.getProject().get(0);
    Assertions.assertEquals(0, element.getValue().size());
}
Also used : CustomFieldDocument(com.synopsys.integration.detect.workflow.blackduck.project.customfields.CustomFieldDocument) CustomFieldElement(com.synopsys.integration.detect.workflow.blackduck.project.customfields.CustomFieldElement) HashMap(java.util.HashMap) Test(org.junit.jupiter.api.Test)

Example 10 with CustomFieldDocument

use of com.synopsys.integration.detect.workflow.blackduck.project.customfields.CustomFieldDocument in project synopsys-detect by blackducksoftware.

the class DetectCustomFieldParserTest method parsedVersion.

@Test
public void parsedVersion() throws DetectUserFriendlyException {
    Map<String, String> props = new HashMap<>();
    props.put("detect.custom.fields.version[0].label", "label");
    props.put("detect.custom.fields.version[0].value", "value1, value2");
    DetectCustomFieldParser parser = new DetectCustomFieldParser();
    CustomFieldDocument document = parser.parseCustomFieldDocument(props);
    Assertions.assertEquals(1, document.getVersion().size());
    CustomFieldElement element = document.getVersion().get(0);
    Assertions.assertEquals("label", element.getLabel());
    Assertions.assertEquals(2, element.getValue().size());
    Assertions.assertTrue(element.getValue().contains("value1"));
    Assertions.assertTrue(element.getValue().contains("value2"));
}
Also used : CustomFieldDocument(com.synopsys.integration.detect.workflow.blackduck.project.customfields.CustomFieldDocument) CustomFieldElement(com.synopsys.integration.detect.workflow.blackduck.project.customfields.CustomFieldElement) HashMap(java.util.HashMap) Test(org.junit.jupiter.api.Test)

Aggregations

CustomFieldDocument (com.synopsys.integration.detect.workflow.blackduck.project.customfields.CustomFieldDocument)11 HashMap (java.util.HashMap)9 Test (org.junit.jupiter.api.Test)9 CustomFieldElement (com.synopsys.integration.detect.workflow.blackduck.project.customfields.CustomFieldElement)7 ProjectVersionWrapper (com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper)1 CloneFindResult (com.synopsys.integration.detect.workflow.blackduck.project.options.CloneFindResult)1 ParentProjectMapOptions (com.synopsys.integration.detect.workflow.blackduck.project.options.ParentProjectMapOptions)1 ProjectGroupFindResult (com.synopsys.integration.detect.workflow.blackduck.project.options.ProjectGroupFindResult)1 ProjectVersionLicenseFindResult (com.synopsys.integration.detect.workflow.blackduck.project.options.ProjectVersionLicenseFindResult)1 Binder (org.springframework.boot.context.properties.bind.Binder)1 ConfigurationPropertySource (org.springframework.boot.context.properties.source.ConfigurationPropertySource)1 MapConfigurationPropertySource (org.springframework.boot.context.properties.source.MapConfigurationPropertySource)1