use of com.synopsys.integration.detect.workflow.blackduck.project.customfields.CustomFieldElement 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());
}
use of com.synopsys.integration.detect.workflow.blackduck.project.customfields.CustomFieldElement 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"));
}
use of com.synopsys.integration.detect.workflow.blackduck.project.customfields.CustomFieldElement in project synopsys-detect by blackducksoftware.
the class DetectCustomFieldParserTest method parsedMissingLabelStillList.
@Test
public void parsedMissingLabelStillList() throws DetectUserFriendlyException {
Map<String, String> props = new HashMap<>();
props.put("detect.custom.fields.project[0].value", "value1");
DetectCustomFieldParser parser = new DetectCustomFieldParser();
CustomFieldDocument document = parser.parseCustomFieldDocument(props);
CustomFieldElement element = document.getProject().get(0);
Assertions.assertEquals("", element.getLabel());
}
use of com.synopsys.integration.detect.workflow.blackduck.project.customfields.CustomFieldElement in project synopsys-detect by blackducksoftware.
the class UpdateCustomFieldsOperation method updateCustomFields.
public void updateCustomFields(ProjectVersionWrapper projectVersionWrapper, CustomFieldDocument customFieldDocument) throws DetectUserFriendlyException {
logger.debug("Will update the following custom fields and values.");
for (CustomFieldElement element : customFieldDocument.getProject()) {
logger.debug(String.format("Project field '%s' will be set to '%s'.", element.getLabel(), String.join(",", element.getValue())));
}
for (CustomFieldElement element : customFieldDocument.getVersion()) {
logger.debug(String.format("Version field '%s' will be set to '%s'.", element.getLabel(), String.join(",", element.getValue())));
}
List<CustomFieldOperation> customFieldOperations = determineOperations(customFieldDocument, projectVersionWrapper, blackDuckService);
executeCustomFieldOperations(customFieldOperations, blackDuckService);
logger.info("Successfully updated (" + (customFieldDocument.getVersion().size() + customFieldDocument.getProject().size()) + ") custom fields.");
}
Aggregations