@Test
public void location_resource_should_be_matched_only_if_capabilities_are_satisfied() throws Exception {

    // Given
    CapabilityDefinition capabilityArchitecture = new CapabilityDefinition("tosca.capabilities.OperatingSystem");
    computeNodeType.setCapabilities(Arrays.asList(capabilityArchitecture));
    Capability capability = new Capability();
    capability.setType("tosca.capabilities.OperatingSystem");
    capability.setProperties(ImmutableMap.of("architecture", new ScalarPropertyValue("x86")));
    computeNodeTemplate.setCapabilities(ImmutableMap.of("os", capability));
    CapabilityType capabilityType = new CapabilityType();
    PropertyDefinition propertyDefinition = new PropertyDefinition();
    propertyDefinition.setType("string");
    capabilityType.setElementId("tosca.capabilities.OperatingSystem");
    capabilityType.setProperties(ImmutableMap.of("architecture", propertyDefinition));
    locationResources.setCapabilityTypes(ImmutableMap.of("tosca.capabilities.OperatingSystem", capabilityType));
    // Matching configuration
    Map<String, MatchingConfiguration> capabilityFilterConfiguration = new HashMap<>();
    MatchingConfiguration matchingConfiguration = new MatchingConfiguration();
    MatchingFilterDefinition matchingFilterDefinition = new MatchingConfiguration();
    matchingFilterDefinition.setProperties(ImmutableMap.of("architecture", Arrays.asList(new EqualConstraint())));
    matchingConfiguration.setCapabilities(ImmutableMap.of("os", matchingFilterDefinition));
    capabilityFilterConfiguration.put("org.alien4cloud.nodes.mock.aws.Compute", matchingConfiguration);
    // When
    NodeTemplate wantedNodeTemplate = new NodeTemplate();
    wantedNodeTemplate.setType("tosca.nodes.Compute");
    Capability wantedCapability = new Capability();
    wantedCapability.setType("tosca.capabilities.OperatingSystem");
    wantedCapability.setProperties(ImmutableMap.of("architecture", new ScalarPropertyValue("power_pc")));
    wantedNodeTemplate.setCapabilities(ImmutableMap.of("os", wantedCapability));
    NodeType nodeType = new NodeType();
    List<LocationResourceTemplate> proposition = nodeMatcher.matchNode(wantedNodeTemplate, nodeType, locationResources, capabilityFilterConfiguration);
    // Then
    assertThat(proposition).hasSize(0);
}