use of org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData in project openflowplugin by opendaylight.
the class MeterConvertorTest method testMeterModCommandConvertorBandDataisNULL.
@Test
public void testMeterModCommandConvertorBandDataisNULL() {
AddMeterInputBuilder addMeterFromSAL = new AddMeterInputBuilder();
// NodeKey key = new NodeKey(new NodeId("24"));
// InstanceIdentifier<Node> path =
// InstanceIdentifier.builder().node(Nodes.class).node(Node.class,
// key).build();
addMeterFromSAL.setMeterId(new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId(10L));
MeterFlags flagV = new MeterFlags(true, true, true, true);
addMeterFromSAL.setFlags(flagV);
AddMeterInput meterInputCommand = addMeterFromSAL.build();
MeterModInputBuilder outMeterModInput = convert(meterInputCommand, new VersionConvertorData((short) 0X4));
assertEquals(MeterModCommand.OFPMCADD, outMeterModInput.getCommand());
assertTrue(outMeterModInput.getFlags().isOFPMFBURST());
assertEquals(Long.valueOf(10L), outMeterModInput.getMeterId().getValue());
}
use of org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData in project openflowplugin by opendaylight.
the class PortConvertorTest method testtoPortModInputwithAllParameters.
/**
* test of {@link PortConvertor#convert(Port, VersionConvertorData)} }.
*/
@Test
public void testtoPortModInputwithAllParameters() {
PortBuilder portBld = new PortBuilder();
portBld.setAdvertisedFeatures(features);
portBld.setConfiguration(config);
portBld.setPortNumber(new PortNumberUni(42L));
portBld.setHardwareAddress(new MacAddress(DEFAULT_MAC_ADDRESS));
VersionConvertorData data = new VersionConvertorData(OFConstants.OFP_VERSION_1_3);
final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
Optional<PortModInput> portOutOptional = convertorManager.convert(portBld.build(), data);
final PortModInput portOut = portOutOptional.orElse(PortConvertor.defaultResult(OFConstants.OFP_VERSION_1_3));
PortConfigV10 portConfV10 = new PortConfigV10(false, false, false, false, true, true, false);
PortModInputBuilder portModInputBld = new PortModInputBuilder();
portModInputBld.setConfig(config31);
portModInputBld.setMask(configMask31);
portModInputBld.setPortNo(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber(42L));
portModInputBld.setHwAddress(new MacAddress(DEFAULT_MAC_ADDRESS));
portModInputBld.setAdvertise(portf31);
portModInputBld.setConfigV10(portConfV10);
portModInputBld.setMaskV10(portConfMaskV10);
portModInputBld.setAdvertiseV10(new PortFeaturesV10(null, null, null, null, null, null, null, true, null, null, null, null));
portModInputBld.setVersion((short) EncodeConstants.OF13_VERSION_ID);
Assert.assertEquals(portModInputBld.build(), portOut);
}
use of org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData in project openflowplugin by opendaylight.
the class ConvertorManagerTest method testConvert1.
/**
* Test for {@link ConvertorManager#convert(Collection, ConvertorData)}.
*/
@Test
public void testConvert1() throws Exception {
final ConvertorManager convertorManager = new ConvertorManager(OFConstants.OFP_VERSION_1_3).registerConvertor(OFConstants.OFP_VERSION_1_3, new Convertor<List<Action>, String, VersionConvertorData>() {
@Override
public Collection<Class<?>> getTypes() {
return Collections.singleton(Action.class);
}
@Override
public String convert(List<Action> source, VersionConvertorData data) {
return String.valueOf(source) + String.valueOf(data);
}
});
final List<Action> source = Collections.singletonList(new ActionBuilder().build());
final VersionConvertorData data = new VersionConvertorData(OFConstants.OFP_VERSION_1_3);
final String expectedResult = String.valueOf(source) + String.valueOf(data);
final Optional<String> result = convertorManager.convert(source, data);
assertTrue("Failed to convert action to string", result.isPresent());
assertEquals("Result and expected result do not match", result.get(), expectedResult);
}
Aggregations