Search in sources :

Example 1 with VplsStoreEvent

use of org.onosproject.vpls.store.VplsStoreEvent in project onos by opennetworkinglab.

the class VplsManagerTest method testStoreDelegate.

/**
 * Pass different VPLS store event to store delegate.
 * Include these cases:
 * <ul>
 *     <li>VPLS added</li>
 *     <li>VPLS updated</li>
 *     <li>VPLS state updated</li>
 *     <li>VPLS removed</li>
 * </ul>
 */
@Test
public void testStoreDelegate() {
    // Add
    VplsData vplsData = vplsManager.createVpls(VPLS1, NONE);
    VplsStoreEvent event = new VplsStoreEvent(VplsStoreEvent.Type.ADD, vplsData);
    vplsStore.delegate().notify(event);
    VplsOperation vplsOperation = vplsOperationService.operation();
    assertEquals(vplsOperation.op(), VplsOperation.Operation.ADD);
    assertEquals(vplsOperation.vpls(), vplsData);
    vplsOperationService.clear();
    // Update info
    vplsData.encapsulationType(EncapsulationType.VLAN);
    vplsData.state(UPDATING);
    event = new VplsStoreEvent(VplsStoreEvent.Type.UPDATE, vplsData);
    vplsStore.delegate().notify(event);
    vplsOperation = vplsOperationService.operation();
    assertEquals(vplsOperation.op(), VplsOperation.Operation.UPDATE);
    assertEquals(vplsOperation.vpls(), vplsData);
    vplsOperationService.clear();
    // Update state (no operation)
    vplsData.state(VplsData.VplsState.ADDED);
    event = new VplsStoreEvent(VplsStoreEvent.Type.UPDATE, vplsData);
    vplsStore.delegate().notify(event);
    vplsOperation = vplsOperationService.operation();
    assertNull(vplsOperation);
    vplsOperationService.clear();
    // Remove
    event = new VplsStoreEvent(VplsStoreEvent.Type.REMOVE, vplsData);
    vplsStore.delegate().notify(event);
    vplsOperation = vplsOperationService.operation();
    assertEquals(vplsOperation.op(), VplsOperation.Operation.REMOVE);
    assertEquals(vplsOperation.vpls(), vplsData);
    vplsOperationService.clear();
}
Also used : VplsStoreEvent(org.onosproject.vpls.store.VplsStoreEvent) VplsData(org.onosproject.vpls.api.VplsData) VplsOperation(org.onosproject.vpls.api.VplsOperation) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 VplsData (org.onosproject.vpls.api.VplsData)1 VplsOperation (org.onosproject.vpls.api.VplsOperation)1 VplsStoreEvent (org.onosproject.vpls.store.VplsStoreEvent)1