Search in sources :

Example 1 with DefaultNextGroup

use of org.onosproject.net.behaviour.DefaultNextGroup in project onos by opennetworkinglab.

the class DistributedFlowObjectiveStoreTest method testFlowObjectiveStore.

@Test
public void testFlowObjectiveStore() {
    NextGroup group1 = new DefaultNextGroup("1".getBytes(Charsets.US_ASCII));
    NextGroup group2 = new DefaultNextGroup("2".getBytes(Charsets.US_ASCII));
    NextGroup group3 = new DefaultNextGroup("3".getBytes(Charsets.US_ASCII));
    int group1Id = store.allocateNextId();
    int group2Id = store.allocateNextId();
    int group3Id = store.allocateNextId();
    NextGroup group1add = store.getNextGroup(group1Id);
    assertThat(group1add, nullValue());
    NextGroup dif = store.getNextGroup(3);
    assertThat(dif, is(nullValue()));
    store.putNextGroup(group1Id, group1);
    store.putNextGroup(group2Id, group2);
    NextGroup group2Query = store.getNextGroup(group2Id);
    assertThat(group2Query.data(), is(group2.data()));
    assertTrue(store.getAllGroups().containsKey(group2Id));
    assertTrue(store.getAllGroups().containsKey(group1Id));
    store.removeNextGroup(group2Id);
    assertTrue(store.getAllGroups().containsKey(group1Id));
    assertFalse(store.getAllGroups().containsKey(group2Id));
    store.removeNextGroup(group1Id);
    assertEquals(store.getAllGroups(), Collections.emptyMap());
    store.putNextGroup(group3Id, group3);
    store.removeNextGroup(group2Id);
    NextGroup nullGroup = store.getNextGroup(group2Id);
    assertThat(nullGroup, nullValue());
    assertThat(store.getAllGroups().size(), is(1));
    assertThat(store.getAllGroups(), IsMapContaining.hasKey(group3Id));
}
Also used : DefaultNextGroup(org.onosproject.net.behaviour.DefaultNextGroup) NextGroup(org.onosproject.net.behaviour.NextGroup) DefaultNextGroup(org.onosproject.net.behaviour.DefaultNextGroup) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 DefaultNextGroup (org.onosproject.net.behaviour.DefaultNextGroup)1 NextGroup (org.onosproject.net.behaviour.NextGroup)1