1 package io.fd.honeycomb.lisp.translate.write;
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertTrue;
5 import static org.junit.Assert.fail;
7 import io.fd.honeycomb.lisp.translate.write.trait.SubtableWriterTestCase;
8 import io.fd.honeycomb.translate.write.WriteFailedException;
9 import io.fd.vpp.jvpp.VppCallbackException;
10 import org.junit.Before;
11 import org.junit.Test;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.EidTable;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTableKey;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.VrfSubtable;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.VrfSubtableBuilder;
17 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
19 public class VrfSubtableCustomizerTest extends SubtableWriterTestCase {
21 private VrfSubtableCustomizer customizer;
22 private InstanceIdentifier<VrfSubtable> validId;
23 private VrfSubtable validData;
27 customizer = new VrfSubtableCustomizer(api);
28 validId = InstanceIdentifier.create(EidTable.class).child(VniTable.class, new VniTableKey(12L))
29 .child(VrfSubtable.class);
30 validData = new VrfSubtableBuilder().setTableId(10L).build();
34 public void testWriteSuccessfull() throws WriteFailedException {
35 whenAddDelEidTableAddDelMapSuccess();
37 customizer.writeCurrentAttributes(validId, validData, writeContext);
38 verifyAddDelEidTableAddDelMapInvokedCorrectly(1, 12, 10, 0);
42 public void testWriteFailed() {
43 whenAddDelEidTableAddDelMapFail();
46 customizer.writeCurrentAttributes(validId, validData, writeContext);
47 } catch (Exception e) {
48 assertTrue(e instanceof WriteFailedException);
50 final WriteFailedException realException = ((WriteFailedException) e);
51 assertEquals(validId, realException.getFailedId());
52 assertTrue(e.getCause() instanceof VppCallbackException);
56 fail("Test should throw exception");
59 @Test(expected = UnsupportedOperationException.class)
60 public void testUpdate() throws WriteFailedException {
61 customizer.updateCurrentAttributes(validId, validData, validData, writeContext);
65 public void testDeleteSuccessfull() throws WriteFailedException {
66 whenAddDelEidTableAddDelMapSuccess();
68 customizer.deleteCurrentAttributes(validId, validData, writeContext);
69 verifyAddDelEidTableAddDelMapInvokedCorrectly(0, 12, 10, 0);
73 public void testDeleteFailed() {
74 whenAddDelEidTableAddDelMapFail();
77 customizer.deleteCurrentAttributes(validId, validData, writeContext);
78 } catch (Exception e) {
79 assertTrue(e instanceof WriteFailedException);
81 final WriteFailedException realException = ((WriteFailedException) e);
82 assertEquals(validId, realException.getFailedId());
83 assertTrue(e.getCause() instanceof VppCallbackException);
87 fail("Test should throw exception");