/** * Retrieve the cache bound to the current thread. * * @return The cache for the current thread, or null if not set */ public static CatalogStructure getCache() { BroadleafRequestContext ctx = BroadleafRequestContext.getBroadleafRequestContext(); Catalog currentCatalog = ctx == null ? null : ctx.getCurrentCatalog(); if (currentCatalog != null) { return MapUtils.getObject(CACHE.get(), currentCatalog.getId()); } else { return MapUtils.getObject(CACHE.get(), DEFAULT_CATALOG_CACHE_KEY); } }
private Capability getOrFailCapability(NodeTemplate nodeTemplate, String capabilityName) { Capability capability = MapUtils.getObject(nodeTemplate.getCapabilities(), capabilityName); if (capability != null) { return capability; } throw new NotFoundException("Capability [" + capabilityName + "] not found in template."); }
AbstractPropertyValue originalValue = MapUtils.getObject(originalProperties, entry.getKey()); if (originalValue == null) { AbstractPropertyValue pv = PropertyUtil.getDefaultPropertyValueFromPropertyDefinition(entry.getValue());
private void assertMapContains(Map<String, String> map, Map<String, String> expectedMap) { for (Entry<String, String> entry : expectedMap.entrySet()) { assertEquals(entry.getValue(), MapUtils.getObject(map, entry.getKey())); } }
private PropertyDefinition getOrFailCapabilityPropertyDefinition(CapabilityType capabilityType, String propertyName) { PropertyDefinition propertyDefinition = MapUtils.getObject(capabilityType.getProperties(), propertyName); if (propertyDefinition != null) { return propertyDefinition; } throw new NotFoundException("Property [" + propertyName + "] not found in capability type [" + capabilityType.getElementId() + "]"); }
@SuppressWarnings({ "unchecked", "rawtypes" }) private <V extends AbstractInstantiableToscaType> void registerOperationOutput(final List<? extends IPaaSTemplate> paaSTemplates, final String interfaceName, final String operationName, final String output, final String formatedAttributeName) { for (IPaaSTemplate<V> paaSTemplate : paaSTemplates) { if (paaSTemplate.getInterfaces() != null) { Interface interfass = MapUtils.getObject(paaSTemplate.getInterfaces(), (interfaceName)); if (interfass != null && interfass.getOperations().containsKey(operationName)) { OperationOutput toAdd = new OperationOutput(output); if (StringUtils.isNotBlank(formatedAttributeName)) { toAdd.getRelatedAttributes().add(formatedAttributeName); } interfass.getOperations().get(operationName).addOutput(toAdd); } } } }
inputArity += opPushable.getInputArity(); outputConnectors = MapUtils.getObject(parent.getActivityOutputMap(), entry.getKey(), Collections.emptyList()); for (IConnectorDescriptor conn : outputConnectors) { childQueue.add(parent.getConnectorActivityMap().get(conn.getConnectorId())); outputConnectors = MapUtils.getObject(parent.getActivityOutputMap(), destId, Collections.emptyList());
@Then("^the following nodes properties values sould be \"(.*?)\"$") public void The_following_nodes_properties_values_should_be(String expectedValue, Map<String, String> nodesProperties) throws Throwable { DeploymentTopologyDTO dto = getDTOAndassertNotNull(); for (Entry<String, String> entry : nodesProperties.entrySet()) { NodeTemplate template = MapUtils.getObject(dto.getTopology().getNodeTemplates(), entry.getKey()); assertNodePropertyValueEquals(template, entry.getValue(), expectedValue); } }
private void assertCapabilityPropertyValueEquals(NodeTemplate node, String capabilityName, String propertyName, String expectedPropertyValue) { assertNotNull(node); Capability capability = MapUtils.getObject(node.getCapabilities(), capabilityName); assertNotNull(capability); AbstractPropertyValue abstractProperty = MapUtils.getObject(capability.getProperties(), propertyName); assertEquals(expectedPropertyValue, PropertyUtil.getScalarValue(abstractProperty)); }
private static void fillRequirementsMap(Map<String, Requirement> map, List<RequirementDefinition> elements, Map<String, Requirement> mapToMerge, boolean adaptToType) { if (elements == null) { return; } for (RequirementDefinition requirement : elements) { Requirement toAddRequirement = MapUtils.getObject(mapToMerge, requirement.getId()); // the type of a requirement is a capability type in TOSCA as they match each other. CapabilityType requirementType = ToscaContext.get(CapabilityType.class, requirement.getType()); if (toAddRequirement == null || !Objects.equals(toAddRequirement.getType(), requirement.getType())) { toAddRequirement = new Requirement(); toAddRequirement.setType(requirement.getType()); } Map<String, AbstractPropertyValue> properties = Maps.newLinkedHashMap(); fillProperties(properties, requirementType != null ? requirementType.getProperties() : null, toAddRequirement.getProperties(), adaptToType); toAddRequirement.setProperties(properties); map.put(requirement.getId(), toAddRequirement); } }
private void assertNodePropertyValueEquals(NodeTemplate node, String propertyName, String expectedPropertyValue) { assertNotNull(node); AbstractPropertyValue abstractProperty = MapUtils.getObject(node.getProperties(), propertyName); assertEquals(expectedPropertyValue, PropertyUtil.getScalarValue(abstractProperty)); }
private PropertyDefinition getPropertyDefinition(String nodeName, String propertyName) throws Throwable { PropertyDefinition propDef = null; String url = String.format("/rest/v1/topologies/%s", Context.getInstance().getTopologyId()); String response = Context.getRestClientInstance().get(url); TopologyDTO topologyDTO = JsonUtil.read(response, TopologyDTO.class, Context.getJsonMapper()).getData(); NodeTemplate template = MapUtils.getObject(topologyDTO.getTopology().getNodeTemplates(), nodeName); if (template != null) { NodeType nodeType = MapUtils.getObject(topologyDTO.getNodeTypes(), template.getType()); if (nodeType != null) { propDef = MapUtils.getObject(nodeType.getProperties(), propertyName); } } if (propDef == null) { throw new NullPointerException( "The property definition is required for node " + nodeName + " and property " + propertyName + ", please check your cucumber scenario."); } return propDef; }
Capability toAddCapa = MapUtils.getObject(mapToMerge, capa.getId()); Map<String, AbstractPropertyValue> capaProperties = null; CapabilityType capabilityType = ToscaContext.get(CapabilityType.class, capa.getType());
@Given("^I define the capability \"(.*?)\" property \"(.*?)\" of the node \"(.*?)\" as input property$") public void i_define_the_capability_property_of_the_node_of_typeId_as_input_property(String capabilityName, String propertyName, String nodeName) throws Throwable { String url = String.format("/rest/v1/topologies/%s", Context.getInstance().getTopologyId()); String response = Context.getRestClientInstance().get(url); TopologyDTO topologyDTO = JsonUtil.read(response, TopologyDTO.class, Context.getJsonMapper()).getData(); NodeTemplate template = MapUtils.getObject(topologyDTO.getTopology().getNodeTemplates(), nodeName); Capability capability = template.getCapabilities().get(capabilityName); CapabilityType capabilityType = topologyDTO.getCapabilityTypes().get(capability.getType()); PropertyDefinition propertyDefinition = capabilityType.getProperties().get(propertyName); String fullUrl = String.format("/rest/v1/topologies/%s/inputs/%s", Context.getInstance().getTopologyId(), propertyName); String json = JsonUtil.toString(propertyDefinition); Context.getInstance().registerRestResponse(Context.getRestClientInstance().postJSon(fullUrl, json)); }