2 * Copyright (c) 2015 Inocybe and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.ovsdb.openstack.netvirt;
11 import static org.junit.Assert.*;
13 import org.junit.Before;
14 import org.junit.Test;
15 import org.opendaylight.ovsdb.openstack.netvirt.AbstractEvent.HandlerType;
16 import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
19 * Unit test for {@link AbstractEvent}
21 public class AbstractEventTest {
23 private AbstractEventChild1 abstractEvent1;
24 private AbstractEventChild2 abstractEvent2;
25 private AbstractEventChild2 abstractEvent3;
27 class AbstractEventChild1 extends AbstractEvent{
28 protected AbstractEventChild1(HandlerType handlerType, Action action) {
29 super(handlerType, action);
34 class AbstractEventChild2 extends AbstractEvent{
35 protected AbstractEventChild2(HandlerType handlerType, Action action) {
36 super(handlerType, action);
43 abstractEvent1 = new AbstractEventChild1(HandlerType.SOUTHBOUND, Action.DELETE);
44 abstractEvent2 = new AbstractEventChild2(HandlerType.NEUTRON_FLOATING_IP, Action.ADD);
45 abstractEvent3 = abstractEvent2;
49 public void testAbstractEvent(){
50 assertEquals("Error, getAction() did not return the correct value", Action.DELETE, abstractEvent1.getAction());
52 assertEquals("Error, getHandlerType() did not return the correct value", HandlerType.SOUTHBOUND, abstractEvent1.getHandlerType());
54 assertTrue("Error, equals() did not succeed", abstractEvent2.equals(abstractEvent3));
56 assertNotNull("Error, hashCode() did not return any value", abstractEvent1.hashCode());
57 assertEquals("Error, hashCode() is not consistent", abstractEvent2.hashCode(), abstractEvent3.hashCode());
59 int transactionId = abstractEvent1.getTransactionId();
60 assertEquals("Error, toString() did not return the correct value",
61 "AbstractEvent [transactionId=" + transactionId + " handlerType=SOUTHBOUND action=DELETE]", abstractEvent1.toString());