use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NspCaseValueBuilder in project openflowplugin by opendaylight.
the class NspConvertor method convert.
@Override
public MatchEntry convert(Extension extension) {
Optional<NxmNxNspGrouping> matchGrouping = MatchUtil.NSP_RESOLVER.getExtension(extension);
if (!matchGrouping.isPresent()) {
throw new CodecPreconditionException(extension);
}
Long value = matchGrouping.get().getNxmNxNsp().getValue();
NspCaseValueBuilder nspCaseValueBuilder = new NspCaseValueBuilder();
nspCaseValueBuilder.setNspValues(new NspValuesBuilder().setNsp(value).build());
return MatchUtil.createDefaultMatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNsp.class, Nxm1Class.class, nspCaseValueBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NspCaseValueBuilder in project openflowplugin by opendaylight.
the class NspCodecTest method createMatchEntry.
private MatchEntry createMatchEntry() {
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
final NspCaseValueBuilder caseBuilder = new NspCaseValueBuilder();
final NspValuesBuilder valuesBuilder = new NspValuesBuilder();
matchEntryBuilder.setOxmClass(Nxm1Class.class);
matchEntryBuilder.setOxmMatchField(NxmNxNsp.class);
matchEntryBuilder.setHasMask(false);
valuesBuilder.setNsp((long) 1);
caseBuilder.setNspValues(valuesBuilder.build());
matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
return matchEntryBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NspCaseValueBuilder in project openflowplugin by opendaylight.
the class NspCodec method deserialize.
@Override
public MatchEntry deserialize(ByteBuf message) {
MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message);
NspCaseValueBuilder nspCaseValueBuilder = new NspCaseValueBuilder();
nspCaseValueBuilder.setNspValues(new NspValuesBuilder().setNsp(message.readUnsignedInt()).build());
matchEntryBuilder.setMatchEntryValue(nspCaseValueBuilder.build());
matchEntryBuilder.setHasMask(false);
return matchEntryBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NspCaseValueBuilder in project openflowplugin by opendaylight.
the class NspConvertorTest method testConvert1.
@Test
public void testConvert1() throws Exception {
final NspValuesBuilder nspValuesBuilder = new NspValuesBuilder().setNsp(Long.valueOf(2L));
final NspCaseValueBuilder nspCaseValueBuilder = new NspCaseValueBuilder().setNspValues(nspValuesBuilder.build());
final NspCaseValue nspCaseValue = nspCaseValueBuilder.build();
when(matchEntry.getMatchEntryValue()).thenReturn(nspCaseValue);
final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = nspConvertor.convert(matchEntry, MatchPath.PACKET_RECEIVED_MATCH);
Assert.assertEquals(2, ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmNxNsp().getValue().longValue());
Assert.assertEquals(extensionAugment.getKey(), NxmNxNspKey.class);
final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = nspConvertor.convert(matchEntry, MatchPath.SWITCH_FLOW_REMOVED_MATCH);
Assert.assertEquals(2, ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject()).getNxmNxNsp().getValue().longValue());
Assert.assertEquals(extensionAugment.getKey(), NxmNxNspKey.class);
final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = nspConvertor.convert(matchEntry, MatchPath.FLOWS_STATISTICS_UPDATE_MATCH);
Assert.assertEquals(2, ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmNxNsp().getValue().longValue());
Assert.assertEquals(extensionAugment.getKey(), NxmNxNspKey.class);
final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment3 = nspConvertor.convert(matchEntry, MatchPath.FLOWS_STATISTICS_RPC_MATCH);
Assert.assertEquals(2, ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmNxNsp().getValue().longValue());
Assert.assertEquals(extensionAugment.getKey(), NxmNxNspKey.class);
}
Aggregations