@@ -0,0 +1,2886 @@
+/*%0A * Copyright (c) 2015 Inocybe and others.  All rights reserved.%0A *%0A * This program and the accompanying materials are made available under the%0A * terms of the Eclipse Public License v1.0 which accompanies this distribution,%0A * and is available at http://www.eclipse.org/legal/epl-v10.html%0A */%0A%0Apackage org.opendaylight.ovsdb.openstack.netvirt.impl;%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.mockito.Matchers.anyString;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.when;%0A%0Aimport java.util.Map;%0A%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.mockito.InjectMocks;%0Aimport org.mockito.Spy;%0Aimport org.opendaylight.ovsdb.openstack.netvirt.NodeCacheManagerEvent;%0Aimport org.opendaylight.ovsdb.openstack.netvirt.api.Action;%0Aimport org.opendaylight.ovsdb.openstack.netvirt.api.NodeCacheListener;%0Aimport org.opendaylight.ovsdb.utils.mdsal.node.NodeUtils;%0Aimport org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;%0Aimport org.osgi.framework.ServiceReference;%0Aimport org.powermock.api.mockito.PowerMockito;%0Aimport org.powermock.core.classloader.annotations.PrepareForTest;%0Aimport org.powermock.modules.junit4.PowerMockRunner;%0A%0Aimport com.google.common.collect.Maps;%0A%0A/**%0A * Unit test for %7B@link NodeCacheManagerImpl%7D%0A */%0A@RunWith(PowerMockRunner.class)%0A@PrepareForTest(NodeUtils.class)%0Apublic class NodeCacheManagerImplTest %7B%0A%0A    @InjectMocks NodeCacheManagerImpl nodeCacheManagerImpl;%0A    @Spy private Map%3CLong, NodeCacheListener%3E handlers = Maps.newHashMap();%0A%0A    @Test%0A    public void testProcessEvent() %7B%0A        NodeCacheManagerEvent ev = mock(NodeCacheManagerEvent.class);%0A        when(ev.getNodeIdentifier()).thenReturn(%22node_identifier%22);%0A%0A        PowerMockito.mockStatic(NodeUtils.class);%0A        when(NodeUtils.getOpenFlowNode(anyString())).thenReturn(mock(Node.class));%0A%0A        when(ev.getAction()).thenReturn(Action.ADD);%0A        nodeCacheManagerImpl.processEvent(ev);%0A        assertEquals(%22Error, did not add the event%22, 1, nodeCacheManagerImpl.getNodes().size());%0A%0A        when(ev.getAction()).thenReturn(Action.DELETE);%0A        nodeCacheManagerImpl.processEvent(ev);%0A        assertEquals(%22Error, did not delete the event%22, 0, nodeCacheManagerImpl.getNodes().size());%0A    %7D%0A%0A    @Test%0A    public void testCacheListenerAddedAndRemoved() %7B%0A        ServiceReference ref = mock(ServiceReference.class);%0A        when(ref.getProperty(org.osgi.framework.Constants.SERVICE_ID)).thenReturn(Long.valueOf(1));%0A%0A        // add%0A        nodeCacheManagerImpl.cacheListenerAdded(ref, mock(NodeCacheListener.class));%0A        assertEquals(%22Error, cacheListenerAdded() did not add any listener%22, 1, handlers.size());%0A        // remove%0A        nodeCacheManagerImpl.cacheListenerRemoved(ref);%0A        assertEquals(%22Error, cacheListenerAdded() did not remove any listener%22, 0, handlers.size());%0A    %7D%0A%7D%0A

Add JUnit testing for NodeCacheManagerImpl class.