use of oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1 in project ddf by codice.
the class SlotTypeHelper method getNameSlotMapDuplicateSlotNamesAllowed.
/**
* This is a convenience method that will iterate through the List of SlotType1 provided and return a mapping of SlotType1 name to a List of SlotType1s
* * If multiple slots share the same name they will be added to the list
*
* @param slots the list of SlotType1s to be mapped, null returns empty map
* @return a mapping of SlotType1 name to List of SlotType1
*/
public Map<String, List<SlotType1>> getNameSlotMapDuplicateSlotNamesAllowed(List<SlotType1> slots) {
Map<String, List<SlotType1>> slotMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(slots)) {
for (SlotType1 slot : slots) {
slotMap.putIfAbsent(slot.getName(), new ArrayList<>());
slotMap.get(slot.getName()).add(slot);
}
}
return slotMap;
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1 in project ddf by codice.
the class SourceConfigurationHandler method getServiceBindingProperties.
/**
* Returns the service binding slots as a map of string properties with the slot name as the key
*
* @param binding ServiceBindingType to generate the map from
* @return A map of service binding slots
*/
private Map<String, Object> getServiceBindingProperties(ServiceBindingType binding) {
Map<String, Object> properties = new HashMap<>();
for (SlotType1 slot : binding.getSlot()) {
List<String> slotValues = slotHelper.getStringValues(slot);
if (CollectionUtils.isEmpty(slotValues)) {
continue;
}
properties.put(slot.getName(), slotValues.size() == 1 ? slotValues.get(0) : slotValues);
}
if (binding.isSetAccessURI() && properties.get(urlBindingName) != null) {
properties.put(properties.get(urlBindingName).toString(), binding.getAccessURI());
}
return properties;
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1 in project ddf by codice.
the class SlotTypeHelperTest method testGetSlotByName.
@Test
public void testGetSlotByName() throws Exception {
List<SlotType1> slots = registryObject.getSlot();
Map<String, SlotType1> slotMap = stHelper.getNameSlotMap(slots);
for (String slotName : slotMap.keySet()) {
SlotType1 slot = slotMap.get(slotName);
assertThat(slot, is(equalTo(stHelper.getSlotByName(slotName, slots))));
}
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1 in project ddf by codice.
the class SlotTypeHelperTest method getDateValues.
@Test
public void getDateValues() throws Exception {
List<SlotType1> slots = registryObject.getSlot();
int expectedSize = 1;
for (SlotType1 slot : slots) {
String slotTypeUC = slot.getSlotType().toUpperCase();
if (slotTypeUC.contains("DATE")) {
List<Date> dates = stHelper.getDateValues(slot);
assertThat(dates, hasSize(expectedSize));
}
}
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1 in project ddf by codice.
the class SlotTypeHelperTest method getNameSlotMapDuplicateSlotNamesAllowed.
@Test
public void getNameSlotMapDuplicateSlotNamesAllowed() throws Exception {
RegistryObjectType rot = getRegistryObjectFromResource("/registry-package-slots-only-with-dup.xml");
List<SlotType1> slots = rot.getSlot();
String duplicateSlotCase = "serviceType";
int expectedSize = 1;
int expectedServiceTypeSize = 2;
Map<String, List<SlotType1>> slotMap = stHelper.getNameSlotMapDuplicateSlotNamesAllowed(slots);
for (SlotType1 slot : slots) {
String slotName = slot.getName();
// duplicate slotCase
if (duplicateSlotCase.equals(slotName)) {
continue;
}
assertThat(slotMap, hasKey(slotName));
assertThat(slotMap.get(slotName), hasSize(expectedSize));
SlotType1 mappedSlot = slotMap.get(slotName).get(0);
assertThat(mappedSlot, is(equalTo(slot)));
}
// ServiceType slot is repeated in the test xml
// Testing that both slots(SOAP & REST) are stored
List<SlotType1> serviceTypes = slotMap.get(duplicateSlotCase);
assertThat(serviceTypes, notNullValue());
assertThat(serviceTypes, hasSize(expectedServiceTypeSize));
for (SlotType1 serviceTypeSlot : serviceTypes) {
String value = stHelper.getStringValues(serviceTypeSlot).get(0);
assertThat(value, anyOf(equalTo("SOAP"), equalTo("REST")));
}
}
Aggregations