ONOS-4086 to ONOS-4091, ONOS-4098 to ONOS-4100:JUNIT for ISIS controller

Change-Id: If3501a55fcbf994cd69facfd97f43b4a4f0f7812
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbAgeTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbAgeTest.java
new file mode 100644
index 0000000..45adbd9
--- /dev/null
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbAgeTest.java
@@ -0,0 +1,171 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.isis.controller.impl.lsdb;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.isis.controller.IsisLspBin;
+import org.onosproject.isis.io.isispacket.IsisHeader;
+import org.onosproject.isis.io.isispacket.pdu.LsPdu;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Unit test case for DefaultIsisLsdbAge.
+ */
+public class DefaultIsisLsdbAgeTest {
+    private DefaultIsisLsdbAge defaultIsisLsdbAge;
+    private IsisLspBin isisLspBin;
+    private int resultInt;
+    private IsisLspBin resultLspBin;
+    private DefaultLspWrapper lspWrapper;
+    private LsPdu lsPdu;
+    private IsisHeader isisHeader;
+    private String lspId = "1234.1234.1234";
+
+    @Before
+    public void setUp() throws Exception {
+        defaultIsisLsdbAge = new DefaultIsisLsdbAge();
+        isisLspBin = new DefaultIsisLspBin(1);
+        lspWrapper = new DefaultLspWrapper();
+        lspWrapper.setBinNumber(1);
+        isisHeader = new IsisHeader();
+        lsPdu = new LsPdu(isisHeader);
+        lsPdu.setLspId(lspId);
+        lspWrapper.setLsPdu(lsPdu);
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        defaultIsisLsdbAge = null;
+        isisLspBin = null;
+    }
+
+    /**
+     * Tests ageCounter() method.
+     */
+    @Test
+    public void testAgeCounter() throws Exception {
+        resultInt = defaultIsisLsdbAge.ageCounter();
+        assertThat(resultInt, is(0));
+    }
+
+    /**
+     * Tests ageCounterRollOver() method.
+     */
+    @Test
+    public void testAgeCounterRollOver() throws Exception {
+        resultInt = defaultIsisLsdbAge.ageCounterRollOver();
+        assertThat(resultInt, is(0));
+    }
+
+    /**
+     * Tests addLspBin() method.
+     */
+    @Test
+    public void testAddLspBin() throws Exception {
+        defaultIsisLsdbAge.addLspBin(1400, isisLspBin);
+        resultLspBin = defaultIsisLsdbAge.getLspBin(1);
+        assertThat(resultLspBin, is(notNullValue()));
+    }
+
+    /**
+     * Tests getLspBin() method.
+     */
+    @Test
+    public void testGetLspBin() throws Exception {
+        defaultIsisLsdbAge.addLspBin(1, isisLspBin);
+        resultLspBin = defaultIsisLsdbAge.getLspBin(1);
+        assertThat(resultLspBin, is(notNullValue()));
+    }
+
+    /**
+     * Tests removeLspFromBin() method.
+     */
+    @Test
+    public void testRemoveLspFromBin() throws Exception {
+        defaultIsisLsdbAge.addLspBin(1400, isisLspBin);
+        defaultIsisLsdbAge.removeLspFromBin(lspWrapper);
+        assertThat(resultLspBin, is(nullValue()));
+    }
+
+    /**
+     * Tests age2Bin() method.
+     */
+    @Test
+    public void testAge2Bin() throws Exception {
+        defaultIsisLsdbAge.age2Bin(1);
+        assertThat(defaultIsisLsdbAge, is(notNullValue()));
+
+        defaultIsisLsdbAge.age2Bin(-1);
+        assertThat(defaultIsisLsdbAge, is(notNullValue()));
+    }
+
+    /**
+     * Tests startDbAging() method.
+     */
+    @Test
+    public void testStartDbAging() throws Exception {
+        defaultIsisLsdbAge.startDbAging();
+        assertThat(defaultIsisLsdbAge, is(notNullValue()));
+    }
+
+    /**
+     * Tests ageLsp() method.
+     */
+    @Test
+    public void testAgeLsp() throws Exception {
+        defaultIsisLsdbAge.age2Bin(1);
+        defaultIsisLsdbAge.startDbAging();
+        defaultIsisLsdbAge.ageLsp();
+        assertThat(defaultIsisLsdbAge, is(notNullValue()));
+    }
+
+    /**
+     * Tests maxAgeLsa() method.
+     */
+    @Test
+    public void testMaxAgeLsa() throws Exception {
+        defaultIsisLsdbAge.age2Bin(1);
+        defaultIsisLsdbAge.startDbAging();
+        defaultIsisLsdbAge.maxAgeLsa();
+        assertThat(defaultIsisLsdbAge, is(notNullValue()));
+
+        defaultIsisLsdbAge.age2Bin(1400);
+        defaultIsisLsdbAge.startDbAging();
+        defaultIsisLsdbAge.maxAgeLsa();
+        assertThat(defaultIsisLsdbAge, is(notNullValue()));
+    }
+
+    /**
+     * Tests refreshLsa() method.
+     */
+    @Test
+    public void testRefreshLsa() throws Exception {
+        defaultIsisLsdbAge.age2Bin(1);
+        defaultIsisLsdbAge.startDbAging();
+        defaultIsisLsdbAge.refreshLsa();
+        assertThat(defaultIsisLsdbAge, is(notNullValue()));
+
+        defaultIsisLsdbAge.age2Bin(1400);
+        defaultIsisLsdbAge.startDbAging();
+        defaultIsisLsdbAge.refreshLsa();
+        assertThat(defaultIsisLsdbAge, is(notNullValue()));
+    }
+}
+
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbTest.java
new file mode 100644
index 0000000..d1c04fe
--- /dev/null
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbTest.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.isis.controller.impl.lsdb;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.isis.controller.IsisLsdb;
+import org.onosproject.isis.controller.IsisLsdbAge;
+import org.onosproject.isis.controller.IsisPduType;
+import org.onosproject.isis.controller.LspWrapper;
+import org.onosproject.isis.io.util.IsisConstants;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Unit test case for DefaultIsisLsdb.
+ */
+public class DefaultIsisLsdbTest {
+    private final int l1LspSeqNo = IsisConstants.STARTLSSEQUENCENUM;
+    private final int l2LspSeqNo = IsisConstants.STARTLSSEQUENCENUM;
+    private final String srcId = "1111.1111.1111";
+
+    private DefaultIsisLsdb defaultIsisLsdb;
+    private IsisLsdbAge lsdbAge = null;
+
+
+    private int resultInt;
+    private Map<String, LspWrapper> resultMap = new ConcurrentHashMap<>();
+    private IsisLsdb resultLsdb;
+    private LspWrapper resultLspWrapper;
+
+
+    @Before
+    public void setUp() throws Exception {
+        defaultIsisLsdb = new DefaultIsisLsdb();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        defaultIsisLsdb = null;
+    }
+
+    /**
+     * Tests initializeDb() method.
+     */
+    @Test
+    public void testInitializeDb() throws Exception {
+        defaultIsisLsdb.initializeDb();
+        assertThat(lsdbAge, is(nullValue()));
+    }
+
+    /**
+     * Tests setL1LspSeqNo() method.
+     */
+    @Test
+    public void testSetL1LspSeqNo() throws Exception {
+        defaultIsisLsdb.setL1LspSeqNo(l1LspSeqNo);
+        assertThat(defaultIsisLsdb, is(notNullValue()));
+    }
+
+    /**
+     * Tests setL2LspSeqNo() method.
+     */
+    @Test
+    public void testSetL2LspSeqNo() throws Exception {
+        defaultIsisLsdb.setL2LspSeqNo(l2LspSeqNo);
+        assertThat(defaultIsisLsdb, is(notNullValue()));
+    }
+
+    /**
+     * Tests setL2LspSeqNo() method.
+     */
+    @Test
+    public void testLspKey() throws Exception {
+        defaultIsisLsdb.lspKey(srcId);
+        assertThat(defaultIsisLsdb, is(notNullValue()));
+    }
+
+    /**
+     * Tests setL2LspSeqNo() method.
+     */
+    @Test
+    public void testGetL1Db() throws Exception {
+        resultMap = defaultIsisLsdb.getL1Db();
+        assertThat(resultMap.isEmpty(), is(true));
+    }
+
+    /**
+     * Tests setL2LspSeqNo() method.
+     */
+    @Test
+    public void testGetL2Db() throws Exception {
+        resultMap = defaultIsisLsdb.getL2Db();
+        assertThat(resultMap.isEmpty(), is(true));
+    }
+
+    /**
+     * Tests setL2LspSeqNo() method.
+     */
+    @Test
+    public void testIsisLsdb() throws Exception {
+        resultLsdb = defaultIsisLsdb.isisLsdb();
+        assertThat(resultLsdb, is(notNullValue()));
+    }
+
+    /**
+     * Tests findLsp() method.
+     */
+    @Test
+    public void testFindLsp() throws Exception {
+        resultLspWrapper = defaultIsisLsdb.findLsp(IsisPduType.L1HELLOPDU, srcId);
+        assertThat(resultLspWrapper, is(nullValue()));
+    }
+}
+
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLspBinTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLspBinTest.java
new file mode 100644
index 0000000..7dd2abb
--- /dev/null
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLspBinTest.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.isis.controller.impl.lsdb;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.isis.controller.LspWrapper;
+
+import java.util.Map;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Unit test case for DefaultIsisLspBin.
+ */
+public class DefaultIsisLspBinTest {
+
+    private DefaultIsisLspBin defaultIsisLspBin;
+    private int result;
+    private String key = "1";
+    private LspWrapper lspWrapper;
+    private LspWrapper result1;
+    private Map<String, LspWrapper> listOfLsp;
+
+    @Before
+    public void setUp() throws Exception {
+        defaultIsisLspBin = new DefaultIsisLspBin(1);
+        lspWrapper = new DefaultLspWrapper();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        defaultIsisLspBin = null;
+    }
+
+    /**
+     * Tests addIsisLsp() method.
+     */
+    @Test
+    public void testAddIsisLsp() throws Exception {
+        defaultIsisLspBin.addIsisLsp(key, lspWrapper);
+        assertThat(defaultIsisLspBin, is(notNullValue()));
+    }
+
+    /**
+     * Tests isisLsp() method.
+     */
+    @Test
+    public void testIsisLsp() throws Exception {
+        defaultIsisLspBin.addIsisLsp(key, lspWrapper);
+        result1 = defaultIsisLspBin.isisLsp(key);
+        assertThat(result1, is(notNullValue()));
+    }
+
+    /**
+     * Tests removeIsisLsp() method.
+     */
+    @Test
+    public void testRemoveIsisLsp() throws Exception {
+        defaultIsisLspBin.addIsisLsp(key, lspWrapper);
+        defaultIsisLspBin.removeIsisLsp(key, lspWrapper);
+        assertThat(defaultIsisLspBin, is(notNullValue()));
+    }
+
+    /**
+     * Tests listOfLsp() method.
+     */
+    @Test
+    public void testListOfLsp() throws Exception {
+        defaultIsisLspBin.addIsisLsp(key, lspWrapper);
+        listOfLsp = defaultIsisLspBin.listOfLsp();
+        assertThat(listOfLsp.size(), is(1));
+    }
+
+    /**
+     * Tests binNumber() method.
+     */
+    @Test
+    public void testBinNumber() throws Exception {
+        result = defaultIsisLspBin.binNumber();
+        assertThat(result, is(1));
+    }
+
+    /**
+     * Tests toString() method.
+     */
+    @Test
+    public void testToString() throws Exception {
+        assertThat(defaultIsisLspBin.toString(), is(notNullValue()));
+    }
+}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultLspWrapperTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultLspWrapperTest.java
new file mode 100644
index 0000000..617dece
--- /dev/null
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultLspWrapperTest.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.isis.controller.impl.lsdb;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.isis.controller.IsisInterface;
+import org.onosproject.isis.controller.impl.DefaultIsisInterface;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Unit test case for DefaultLspWrapper.
+ */
+public class DefaultLspWrapperTest {
+
+    private DefaultLspWrapper defaultLspWrapper;
+    private String processing = "processing";
+    private String result;
+    private int result1;
+    private IsisInterface isisInterface;
+    private IsisInterface result2;
+
+    @Before
+    public void setUp() throws Exception {
+        defaultLspWrapper = new DefaultLspWrapper();
+        isisInterface = new DefaultIsisInterface();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        defaultLspWrapper = null;
+    }
+
+    /**
+     * Tests lspProcessing() getter method.
+     */
+    @Test
+    public void testLspProcessing() throws Exception {
+        defaultLspWrapper.setLspProcessing(processing);
+        result = defaultLspWrapper.lspProcessing();
+        assertThat(result, is(notNullValue()));
+    }
+
+    /**
+     * Tests lspProcessing() setter method.
+     */
+    @Test
+    public void testSetLspProcessing() throws Exception {
+        defaultLspWrapper.setLspProcessing(processing);
+        result = defaultLspWrapper.lspProcessing();
+        assertThat(result, is(notNullValue()));
+    }
+
+    /**
+     * Tests lspAgeReceived() getter method.
+     */
+    @Test
+    public void testLspAgeReceived() throws Exception {
+        defaultLspWrapper.setLspAgeReceived(1);
+        result1 = defaultLspWrapper.lspAgeReceived();
+        assertThat(result1, is(notNullValue()));
+    }
+
+    /**
+     * Tests lspAgeReceived() setter method.
+     */
+    @Test
+    public void testSetLspAgeReceived() throws Exception {
+        defaultLspWrapper.setLspAgeReceived(1);
+        result1 = defaultLspWrapper.lspAgeReceived();
+        assertThat(result1, is(notNullValue()));
+    }
+
+    /**
+     * Tests lspAgeReceived() getter method.
+     */
+    @Test
+    public void testIsisInterface() throws Exception {
+        defaultLspWrapper.setIsisInterface(isisInterface);
+        result2 = defaultLspWrapper.isisInterface();
+        assertThat(result2, is(notNullValue()));
+    }
+
+    /**
+     * Tests lspAgeReceived() getter method.
+     */
+    @Test
+    public void testSetIsisInterface() throws Exception {
+        defaultLspWrapper.setIsisInterface(isisInterface);
+        result2 = defaultLspWrapper.isisInterface();
+        assertThat(result2, is(notNullValue()));
+    }
+
+}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumerTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumerTest.java
new file mode 100644
index 0000000..2e592af
--- /dev/null
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumerTest.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.isis.controller.impl.lsdb;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.concurrent.BlockingQueue;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Unit test case for IsisLspQueueConsumer.
+ */
+public class IsisLspQueueConsumerTest {
+
+    private IsisLspQueueConsumer isisLspQueueConsumer;
+    private BlockingQueue blockingQueue;
+
+    @Before
+    public void setUp() throws Exception {
+        isisLspQueueConsumer = new IsisLspQueueConsumer(blockingQueue);
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        isisLspQueueConsumer = null;
+    }
+
+    /**
+     * Tests run() method.
+     */
+    @Test
+    public void testRun() throws Exception {
+        isisLspQueueConsumer.run();
+        assertThat(isisLspQueueConsumer, is(notNullValue()));
+    }
+}
\ No newline at end of file