Search in sources :

Example 1 with Builder

use of org.projectfloodlight.openflow.protocol.OFGroupDescStatsReply.Builder in project open-kilda by telstra.

the class OfGroupConverterTest method testConvertToGroupSpeakerData.

@Test
public void testConvertToGroupSpeakerData() {
    OFFactoryVer13 factory = new OFFactoryVer13();
    Builder builder = factory.buildGroupDescStatsReply();
    List<OFGroupDescStatsEntry> entries = new ArrayList<>();
    entries.add(getOfGroupEntry(factory));
    builder.setEntries(entries);
    List<GroupSpeakerData> groupSpeakerDataList = OfGroupConverter.INSTANCE.convertToGroupSpeakerData(builder.build());
    assertEquals(1, groupSpeakerDataList.size());
    GroupSpeakerData groupSpeakerData = groupSpeakerDataList.get(0);
    assertEquals(new GroupId(GROUP_ID), groupSpeakerData.getGroupId());
    assertEquals(GroupType.ALL, groupSpeakerData.getType());
    List<Bucket> buckets = groupSpeakerData.getBuckets();
    Set<Bucket> expectedBuckets = new HashSet<>();
    expectedBuckets.add(Bucket.builder().watchPort(WatchPort.ANY).watchGroup(WatchGroup.ALL).writeActions(Sets.newHashSet(new PortOutAction(new PortNumber(2, null)))).build());
    expectedBuckets.add(Bucket.builder().watchPort(WatchPort.ANY).watchGroup(WatchGroup.ALL).writeActions(Sets.newHashSet(new PortOutAction(new PortNumber(1, null)))).build());
    assertEquals(expectedBuckets, new HashSet<>(buckets));
}
Also used : OFFactoryVer13(org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) OFGroupDescStatsEntry(org.projectfloodlight.openflow.protocol.OFGroupDescStatsEntry) Builder(org.projectfloodlight.openflow.protocol.OFGroupDescStatsReply.Builder) ArrayList(java.util.ArrayList) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) GroupId(org.openkilda.model.GroupId) OFBucket(org.projectfloodlight.openflow.protocol.OFBucket) Bucket(org.openkilda.rulemanager.group.Bucket) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Test (org.junit.Test)1 GroupId (org.openkilda.model.GroupId)1 GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)1 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)1 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)1 Bucket (org.openkilda.rulemanager.group.Bucket)1 OFBucket (org.projectfloodlight.openflow.protocol.OFBucket)1 OFGroupDescStatsEntry (org.projectfloodlight.openflow.protocol.OFGroupDescStatsEntry)1 Builder (org.projectfloodlight.openflow.protocol.OFGroupDescStatsReply.Builder)1 OFFactoryVer13 (org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13)1