-/**
+/*
* Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.openflowplugin.applications.topology.lldp;
import static org.junit.Assert.assertFalse;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.NotificationPublishService;
import org.opendaylight.mdsal.eos.binding.api.Entity;
import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
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;
+import org.opendaylight.yangtools.yang.common.Uint32;
/**
* Test for {@link LLDPLinkAger}.
*/
@RunWith(MockitoJUnitRunner.class)
public class LLDPLinkAgerTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(LLDPLinkAgerTest.class);
-
- private static final long LLDP_INTERVAL = 5L;
- private static final long LINK_EXPIRATION_TIME = 10L;
+ private static final Uint32 LLDP_INTERVAL = Uint32.valueOf(5);
+ private static final Uint32 LINK_EXPIRATION_TIME = Uint32.TEN;
/**
* We need to wait while other tasks are finished before we can check anything in LLDPAgingTask.
@Mock
private EntityOwnershipService eos;
@Mock
+ private DataBroker dataBroker;
+ @Mock
private LinkRemoved linkRemoved;
+
@Before
public void setUp() {
- lldpLinkAger = new LLDPLinkAger(getConfig(), notificationService, getConfigurationService(), eos);
+ lldpLinkAger = new LLDPLinkAger(getConfig(), notificationService, getConfigurationService(), eos, dataBroker);
Mockito.when(link.getDestination()).thenReturn(new NodeConnectorRef(
InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId("openflow:1")))));
Mockito.when(eos.getOwnershipState(any(Entity.class))).thenReturn(
verify(notificationService).putNotification(any(LinkRemoved.class));
}
- private TopologyLldpDiscoveryConfig getConfig() {
+ private static TopologyLldpDiscoveryConfig getConfig() {
TopologyLldpDiscoveryConfigBuilder cfgBuilder = new TopologyLldpDiscoveryConfigBuilder();
cfgBuilder.setTopologyLldpInterval(new NonZeroUint32Type(LLDP_INTERVAL));
cfgBuilder.setTopologyLldpExpirationInterval(new NonZeroUint32Type(LINK_EXPIRATION_TIME));
return cfgBuilder.build();
}
- private ConfigurationService getConfigurationService() {
+ private static ConfigurationService getConfigurationService() {
final ConfigurationService configurationService = Mockito.mock(ConfigurationService.class);
final TopologyLldpDiscoveryConfig config = getConfig();