@Test public void testCheckPhysicalNodeAttributeSatisfied() throws Exception{ method = class1.getDeclaredMethod("checkPhysicalNodeAttributeSatisfied",new Class[]{ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.node.instance.Attribute.class, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement.class }); method.setAccessible(true); org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.node.instance.Attribute attribute = mock(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.node.instance.Attribute.class); org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement physicalResourceRequirement = mock(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement.class); AttributeMatchPatterns attributeMatchPatterns_temp = mock(AttributeMatchPatterns.class); AttributeName attributeName = mock(AttributeName.class); ReadOnlyTransaction readOnlyTransaction = mock(ReadOnlyTransaction.class); PhysicalNodeAttributeDefinition physicalNodeAttributeDefinition = mock(PhysicalNodeAttributeDefinition.class); CheckedFuture checkedFuture = mock(CheckedFuture.class); AttributeValue attributeValue = mock(AttributeValue.class); AttributeMatchPatterns.AttributeMatchPattern attributeMatchPattern_in_list = AttributeMatchPatterns.AttributeMatchPattern.LessThan; Optional<PhysicalNodeAttributeDefinition> result = Optional.of(physicalNodeAttributeDefinition); List<AttributeMatchPatterns.AttributeMatchPattern> attributeMatchPatterns = new ArrayList<AttributeMatchPatterns.AttributeMatchPattern>(); org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement.AttributeMatchPattern attributeMatchPattern = org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement.AttributeMatchPattern.LessThan; attributeMatchPatterns.add(attributeMatchPattern_in_list); when(dataBroker.newReadOnlyTransaction()).thenReturn(readOnlyTransaction); when(readOnlyTransaction.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class))).thenReturn(checkedFuture); when(checkedFuture.get()).thenReturn(result); when(physicalNodeAttributeDefinition.getAttributeMatchPatterns()).thenReturn(attributeMatchPatterns_temp); when(attributeMatchPatterns_temp.getAttributeMatchPattern()).thenReturn(attributeMatchPatterns); when(physicalResourceRequirement.getAttributeMatchPattern()).thenReturn(attributeMatchPattern); when(attribute.getAttributeName()).thenReturn(attributeName); when(physicalNodeAttributeDefinition.getAttributeValueType()).thenReturn(AttributeValueType.Int); when(attribute.getAttributeValue()).thenReturn(attributeValue); when(attributeValue.getIntValue()) .thenReturn(1L) .thenReturn(2L); when(physicalResourceRequirement.getAttributeValue()).thenReturn(attributeValue); Assert.assertTrue((boolean) method.invoke(vnMappingUnit,attribute,physicalResourceRequirement)); }
private boolean checkPhysicalNodeAttributeSatisfied( org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.node.instance.Attribute attribute, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement physicalResourceRequirement) throws VNMappingException { ReadOnlyTransaction readOnlyTransaction = dataBroker.newReadOnlyTransaction(); InstanceIdentifier<PhysicalNodeAttributeDefinition> physicalNodeAttributeDefinitionIid = InstanceIdentifier .builder(PhysicalNodeAttributeDefinitions.class) .child(PhysicalNodeAttributeDefinition.class, new PhysicalNodeAttributeDefinitionKey(attribute.getAttributeName())) .build(); Optional<PhysicalNodeAttributeDefinition> result; try { result = readOnlyTransaction.read(LogicalDatastoreType.CONFIGURATION, physicalNodeAttributeDefinitionIid).get(); } catch ( InterruptedException exception ) { throw new VNMappingException("Can not read the physical node attribute definition " + "with attribute name " + attribute.getAttributeName().getValue() + "."); } catch ( ExecutionException exception ) { throw new VNMappingException("Can not read the physical node attribute definition " + "with attribute name " + attribute.getAttributeName().getValue() + "."); } if ( !result.isPresent() ) { throw new VNMappingException("The physical node attribute definition with attribute name " + attribute.getAttributeName().getValue() + " does not exist."); } PhysicalNodeAttributeDefinition physicalNodeAttributeDefinition = result.get(); List<AttributeMatchPatterns.AttributeMatchPattern> attributeMatchPatterns = physicalNodeAttributeDefinition.getAttributeMatchPatterns().getAttributeMatchPattern(); org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement.AttributeMatchPattern attributeMatchPattern = physicalResourceRequirement.getAttributeMatchPattern(); if ( !checkAttributeMatchPatternSpecified(attributeMatchPatterns, attributeMatchPattern) ) { throw new VNMappingException("The attribute match pattern " + attributeMatchPattern + " is not specified in the physical node attribute definition " + "with attribute name " + attribute.getAttributeName().getValue() + "."); } switch ( physicalNodeAttributeDefinition.getAttributeValueType() ) { case String: return checkAttributeStringValueSatisfied(attribute.getAttributeValue().getStringValue(), physicalResourceRequirement.getAttributeValue().getStringValue(), attributeMatchPattern); case Int: return checkAttributeIntegerValueSatisfied(attribute.getAttributeValue().getIntValue(), physicalResourceRequirement.getAttributeValue().getIntValue(), attributeMatchPattern); case Range: return checkAttributeRangeValueSatisfied(attribute.getAttributeValue().getIntValue(), physicalResourceRequirement.getAttributeValue().getRangeValue(), attributeMatchPattern); default: throw new VNMappingException("Unsupported physical node attribute value type " + physicalNodeAttributeDefinition.getAttributeValueType() + "."); } }
VNMappingUnit implements AutoCloseable { private boolean checkPhysicalNodeAttributeSatisfied( org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.node.instance.Attribute attribute, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement physicalResourceRequirement) throws VNMappingException { ReadOnlyTransaction readOnlyTransaction = dataBroker.newReadOnlyTransaction(); InstanceIdentifier<PhysicalNodeAttributeDefinition> physicalNodeAttributeDefinitionIid = InstanceIdentifier .builder(PhysicalNodeAttributeDefinitions.class) .child(PhysicalNodeAttributeDefinition.class, new PhysicalNodeAttributeDefinitionKey(attribute.getAttributeName())) .build(); Optional<PhysicalNodeAttributeDefinition> result; try { result = readOnlyTransaction.read(LogicalDatastoreType.CONFIGURATION, physicalNodeAttributeDefinitionIid).get(); } catch ( InterruptedException exception ) { throw new VNMappingException("Can not read the physical node attribute definition " + "with attribute name " + attribute.getAttributeName().getValue() + "."); } catch ( ExecutionException exception ) { throw new VNMappingException("Can not read the physical node attribute definition " + "with attribute name " + attribute.getAttributeName().getValue() + "."); } if ( !result.isPresent() ) { throw new VNMappingException("The physical node attribute definition with attribute name " + attribute.getAttributeName().getValue() + " does not exist."); } PhysicalNodeAttributeDefinition physicalNodeAttributeDefinition = result.get(); List<AttributeMatchPatterns.AttributeMatchPattern> attributeMatchPatterns = physicalNodeAttributeDefinition.getAttributeMatchPatterns().getAttributeMatchPattern(); org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement.AttributeMatchPattern attributeMatchPattern = physicalResourceRequirement.getAttributeMatchPattern(); if ( !checkAttributeMatchPatternSpecified(attributeMatchPatterns, attributeMatchPattern) ) { throw new VNMappingException("The attribute match pattern " + attributeMatchPattern + " is not specified in the physical node attribute definition " + "with attribute name " + attribute.getAttributeName().getValue() + "."); } switch ( physicalNodeAttributeDefinition.getAttributeValueType() ) { case String: return checkAttributeStringValueSatisfied(attribute.getAttributeValue().getStringValue(), physicalResourceRequirement.getAttributeValue().getStringValue(), attributeMatchPattern); case Int: return checkAttributeIntegerValueSatisfied(attribute.getAttributeValue().getIntValue(), physicalResourceRequirement.getAttributeValue().getIntValue(), attributeMatchPattern); case Range: return checkAttributeRangeValueSatisfied(attribute.getAttributeValue().getIntValue(), physicalResourceRequirement.getAttributeValue().getRangeValue(), attributeMatchPattern); default: throw new VNMappingException("Unsupported physical node attribute value type " + physicalNodeAttributeDefinition.getAttributeValueType() + "."); } } }
VNMappingUnit implements AutoCloseable { private boolean checkPhysicalNodeAttributeSatisfied( org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.node.instance.Attribute attribute, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement physicalResourceRequirement) throws VNMappingException { ReadOnlyTransaction readOnlyTransaction = dataBroker.newReadOnlyTransaction(); InstanceIdentifier<PhysicalNodeAttributeDefinition> physicalNodeAttributeDefinitionIid = InstanceIdentifier .builder(PhysicalNodeAttributeDefinitions.class) .child(PhysicalNodeAttributeDefinition.class, new PhysicalNodeAttributeDefinitionKey(attribute.getAttributeName())) .build(); Optional<PhysicalNodeAttributeDefinition> result; try { result = readOnlyTransaction.read(LogicalDatastoreType.CONFIGURATION, physicalNodeAttributeDefinitionIid).get(); } catch ( InterruptedException exception ) { throw new VNMappingException("Can not read the physical node attribute definition " + "with attribute name " + attribute.getAttributeName().getValue() + "."); } catch ( ExecutionException exception ) { throw new VNMappingException("Can not read the physical node attribute definition " + "with attribute name " + attribute.getAttributeName().getValue() + "."); } if ( !result.isPresent() ) { throw new VNMappingException("The physical node attribute definition with attribute name " + attribute.getAttributeName().getValue() + " does not exist."); } PhysicalNodeAttributeDefinition physicalNodeAttributeDefinition = result.get(); List<AttributeMatchPatterns.AttributeMatchPattern> attributeMatchPatterns = physicalNodeAttributeDefinition.getAttributeMatchPatterns().getAttributeMatchPattern(); org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement.AttributeMatchPattern attributeMatchPattern = physicalResourceRequirement.getAttributeMatchPattern(); if ( !checkAttributeMatchPatternSpecified(attributeMatchPatterns, attributeMatchPattern) ) { throw new VNMappingException("The attribute match pattern " + attributeMatchPattern + " is not specified in the physical node attribute definition " + "with attribute name " + attribute.getAttributeName().getValue() + "."); } switch ( physicalNodeAttributeDefinition.getAttributeValueType() ) { case String: return checkAttributeStringValueSatisfied(attribute.getAttributeValue().getStringValue(), physicalResourceRequirement.getAttributeValue().getStringValue(), attributeMatchPattern); case Int: return checkAttributeIntegerValueSatisfied(attribute.getAttributeValue().getIntValue(), physicalResourceRequirement.getAttributeValue().getIntValue(), attributeMatchPattern); case Range: return checkAttributeRangeValueSatisfied(attribute.getAttributeValue().getIntValue(), physicalResourceRequirement.getAttributeValue().getRangeValue(), attributeMatchPattern); default: throw new VNMappingException("Unsupported physical node attribute value type " + physicalNodeAttributeDefinition.getAttributeValueType() + "."); } } VNMappingUnit(DataBroker dataBroker,
                         PNComputationUnit pnComputationUnit,
                         PNResourcesTracker pnResourcesTracker); }
VNMappingUnit implements AutoCloseable { private boolean checkPhysicalNodeAttributeSatisfied( org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.node.instance.Attribute attribute, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement physicalResourceRequirement) throws VNMappingException { ReadOnlyTransaction readOnlyTransaction = dataBroker.newReadOnlyTransaction(); InstanceIdentifier<PhysicalNodeAttributeDefinition> physicalNodeAttributeDefinitionIid = InstanceIdentifier .builder(PhysicalNodeAttributeDefinitions.class) .child(PhysicalNodeAttributeDefinition.class, new PhysicalNodeAttributeDefinitionKey(attribute.getAttributeName())) .build(); Optional<PhysicalNodeAttributeDefinition> result; try { result = readOnlyTransaction.read(LogicalDatastoreType.CONFIGURATION, physicalNodeAttributeDefinitionIid).get(); } catch ( InterruptedException exception ) { throw new VNMappingException("Can not read the physical node attribute definition " + "with attribute name " + attribute.getAttributeName().getValue() + "."); } catch ( ExecutionException exception ) { throw new VNMappingException("Can not read the physical node attribute definition " + "with attribute name " + attribute.getAttributeName().getValue() + "."); } if ( !result.isPresent() ) { throw new VNMappingException("The physical node attribute definition with attribute name " + attribute.getAttributeName().getValue() + " does not exist."); } PhysicalNodeAttributeDefinition physicalNodeAttributeDefinition = result.get(); List<AttributeMatchPatterns.AttributeMatchPattern> attributeMatchPatterns = physicalNodeAttributeDefinition.getAttributeMatchPatterns().getAttributeMatchPattern(); org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement.AttributeMatchPattern attributeMatchPattern = physicalResourceRequirement.getAttributeMatchPattern(); if ( !checkAttributeMatchPatternSpecified(attributeMatchPatterns, attributeMatchPattern) ) { throw new VNMappingException("The attribute match pattern " + attributeMatchPattern + " is not specified in the physical node attribute definition " + "with attribute name " + attribute.getAttributeName().getValue() + "."); } switch ( physicalNodeAttributeDefinition.getAttributeValueType() ) { case String: return checkAttributeStringValueSatisfied(attribute.getAttributeValue().getStringValue(), physicalResourceRequirement.getAttributeValue().getStringValue(), attributeMatchPattern); case Int: return checkAttributeIntegerValueSatisfied(attribute.getAttributeValue().getIntValue(), physicalResourceRequirement.getAttributeValue().getIntValue(), attributeMatchPattern); case Range: return checkAttributeRangeValueSatisfied(attribute.getAttributeValue().getIntValue(), physicalResourceRequirement.getAttributeValue().getRangeValue(), attributeMatchPattern); default: throw new VNMappingException("Unsupported physical node attribute value type " + physicalNodeAttributeDefinition.getAttributeValueType() + "."); } } VNMappingUnit(DataBroker dataBroker,
                         PNComputationUnit pnComputationUnit,
                         PNResourcesTracker pnResourcesTracker); void virtualNetworkMapping(VirtualNetwork virtualNetwork, UserVnPnMapping userVnPnMapping,
                                      List<PhysicalPath> physicalPaths); void virtualNetworkMapping(VirtualNetwork virtualNetwork, List<VirtualLink> unmappedVirtualLinks,
                                      UserVnPnMapping userVnPnMapping, List<PhysicalPath> physicalPaths); @Override void close(); }
VNMappingUnit implements AutoCloseable { private boolean checkPhysicalNodeAttributeSatisfied( org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.node.instance.Attribute attribute, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement physicalResourceRequirement) throws VNMappingException { ReadOnlyTransaction readOnlyTransaction = dataBroker.newReadOnlyTransaction(); InstanceIdentifier<PhysicalNodeAttributeDefinition> physicalNodeAttributeDefinitionIid = InstanceIdentifier .builder(PhysicalNodeAttributeDefinitions.class) .child(PhysicalNodeAttributeDefinition.class, new PhysicalNodeAttributeDefinitionKey(attribute.getAttributeName())) .build(); Optional<PhysicalNodeAttributeDefinition> result; try { result = readOnlyTransaction.read(LogicalDatastoreType.CONFIGURATION, physicalNodeAttributeDefinitionIid).get(); } catch ( InterruptedException exception ) { throw new VNMappingException("Can not read the physical node attribute definition " + "with attribute name " + attribute.getAttributeName().getValue() + "."); } catch ( ExecutionException exception ) { throw new VNMappingException("Can not read the physical node attribute definition " + "with attribute name " + attribute.getAttributeName().getValue() + "."); } if ( !result.isPresent() ) { throw new VNMappingException("The physical node attribute definition with attribute name " + attribute.getAttributeName().getValue() + " does not exist."); } PhysicalNodeAttributeDefinition physicalNodeAttributeDefinition = result.get(); List<AttributeMatchPatterns.AttributeMatchPattern> attributeMatchPatterns = physicalNodeAttributeDefinition.getAttributeMatchPatterns().getAttributeMatchPattern(); org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement.AttributeMatchPattern attributeMatchPattern = physicalResourceRequirement.getAttributeMatchPattern(); if ( !checkAttributeMatchPatternSpecified(attributeMatchPatterns, attributeMatchPattern) ) { throw new VNMappingException("The attribute match pattern " + attributeMatchPattern + " is not specified in the physical node attribute definition " + "with attribute name " + attribute.getAttributeName().getValue() + "."); } switch ( physicalNodeAttributeDefinition.getAttributeValueType() ) { case String: return checkAttributeStringValueSatisfied(attribute.getAttributeValue().getStringValue(), physicalResourceRequirement.getAttributeValue().getStringValue(), attributeMatchPattern); case Int: return checkAttributeIntegerValueSatisfied(attribute.getAttributeValue().getIntValue(), physicalResourceRequirement.getAttributeValue().getIntValue(), attributeMatchPattern); case Range: return checkAttributeRangeValueSatisfied(attribute.getAttributeValue().getIntValue(), physicalResourceRequirement.getAttributeValue().getRangeValue(), attributeMatchPattern); default: throw new VNMappingException("Unsupported physical node attribute value type " + physicalNodeAttributeDefinition.getAttributeValueType() + "."); } } VNMappingUnit(DataBroker dataBroker,
                         PNComputationUnit pnComputationUnit,
                         PNResourcesTracker pnResourcesTracker); void virtualNetworkMapping(VirtualNetwork virtualNetwork, UserVnPnMapping userVnPnMapping,
                                      List<PhysicalPath> physicalPaths); void virtualNetworkMapping(VirtualNetwork virtualNetwork, List<VirtualLink> unmappedVirtualLinks,
                                      UserVnPnMapping userVnPnMapping, List<PhysicalPath> physicalPaths); @Override void close();  }