import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.verify;
+import com.google.common.base.Optional;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.mdsal.eos.binding.api.Entity;
+import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
+import org.opendaylight.mdsal.eos.common.api.EntityOwnershipState;
import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkDiscovered;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.lldp.discovery.config.rev160511.NonZeroUint32Type;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.lldp.discovery.config.rev160511.TopologyLldpDiscoveryConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.lldp.discovery.config.rev160511.TopologyLldpDiscoveryConfigBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger LOG = LoggerFactory.getLogger(LLDPLinkAgerTest.class);
- private LLDPLinkAger lldpLinkAger;
- private final long LLDP_INTERVAL = 5L;
- private final long LINK_EXPIRATION_TIME = 10L;
+ private static final long LLDP_INTERVAL = 5L;
+ private static final long LINK_EXPIRATION_TIME = 10L;
+
/**
- * We need to wait while other tasks are finished before we can check anything
- * in LLDPAgingTask
+ * We need to wait while other tasks are finished before we can check anything in LLDPAgingTask.
*/
- private final int SLEEP = 100;
+ private static final int SLEEP = 100;
+
+ private LLDPLinkAger lldpLinkAger;
@Mock
private LinkDiscovered link;
@Mock
private NotificationProviderService notificationService;
+ @Mock
+ private EntityOwnershipService eos;
+ @Mock
+ private LinkRemoved linkRemoved;
@Before
public void setUp() throws Exception {
- lldpLinkAger = new LLDPLinkAger(getConfig(), notificationService, getConfigurationService());
+ lldpLinkAger = new LLDPLinkAger(getConfig(), notificationService, getConfigurationService(), eos);
+ Mockito.when(link.getDestination()).thenReturn(new NodeConnectorRef(
+ InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId("openflow:1")))));
+ Mockito.when(eos.getOwnershipState(Mockito.any(Entity.class))).thenReturn(
+ Optional.of(EntityOwnershipState.IS_OWNER));
}
@Test
}
/**
- * Inner class LLDPAgingTask removes all expired records from linkToDate if any (in constructor of LLDPLinkAger)
+ * Inner class LLDPAgingTask removes all expired records from linkToDate if any (in constructor of LLDPLinkAger).
*/
@Test
public void testLLDPAgingTask() throws InterruptedException {
return configurationService;
}
-}
\ No newline at end of file
+}