Replace reflection access with package @VisibleForTesting fields.
Change-Id: Ic900de4ae5efa8123e1c2ca377b442d39ab011ea
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-binding-spi</artifactId>
</dependency>
- <!-- Testing Dependencies -->
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <scope>test</scope>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.core</artifactId>
</dependency>
+
+ <!-- Testing Dependencies -->
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-binding-test-utils</artifactId>
</dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-reflect</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.core</artifactId>
- </dependency>
</dependencies>
<build>
import static org.opendaylight.ovsdb.lib.operations.Operations.op;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
public class McastMacsRemoteUpdateCommand
extends AbstractTransactCommand<RemoteMcastMacs, RemoteMcastMacsKey, HwvtepGlobalAugmentation> {
private static final Logger LOG = LoggerFactory.getLogger(McastMacsRemoteUpdateCommand.class);
- private static final McastMacUnMetDependencyGetter MCAST_MAC_DATA_VALIDATOR = new McastMacUnMetDependencyGetter();
+
+ @VisibleForTesting
+ static final McastMacUnMetDependencyGetter MCAST_MAC_DATA_VALIDATOR = new McastMacUnMetDependencyGetter();
public McastMacsRemoteUpdateCommand(final HwvtepOperationalState state,
final Collection<DataTreeModification<Node>> changes) {
import org.slf4j.LoggerFactory;
public class DataChangeListenerTestBase extends AbstractDataBrokerTest {
-
- static Logger LOG = LoggerFactory.getLogger(DataChangeListenerTestBase.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DataChangeListenerTestBase.class);
static DataBroker dataBroker;
Operations operations;
HwvtepDataChangeListener hwvtepDataChangeListener;
HwvtepConnectionManager hwvtepConnectionManager;
- HwvtepConnectionInstance connectionInstance;
+ protected HwvtepConnectionInstance connectionInstance;
ArgumentCaptor<TypedBaseTable> insertOpCapture;
ArgumentCaptor<List> transactCaptor;
String nodeUuid;
- InstanceIdentifier<Node> nodeIid;
+ protected InstanceIdentifier<Node> nodeIid;
InstanceIdentifier<LogicalSwitches> ls0Iid;
InstanceIdentifier<LogicalSwitches> ls1Iid;
deleteNode(LogicalDatastoreType.CONFIGURATION);
}
- static final void setFinalStatic(final Class<?> cls, final String fieldName, final Object newValue)
+ protected static final void setFinalStatic(final Class<?> cls, final String fieldName, final Object newValue)
throws SecurityException, ReflectiveOperationException {
Field[] fields = FieldUtils.getAllFields(cls);
for (Field field : fields) {
tx.commit();
}
- Node addData(final LogicalDatastoreType logicalDatastoreType, final Class<? extends DataObject> dataObject,
- final String[]... data) {
+ protected final Node addData(final LogicalDatastoreType logicalDatastoreType,
+ final Class<? extends DataObject> dataObject, final String[]... data) {
NodeBuilder nodeBuilder = prepareNode(nodeIid);
HwvtepGlobalAugmentationBuilder builder = new HwvtepGlobalAugmentationBuilder();
if (LogicalSwitches.class == dataObject) {
* 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.ovsdb.hwvtepsouthbound;
+package org.opendaylight.ovsdb.hwvtepsouthbound.transact;
import static org.junit.Assert.assertEquals;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.ovsdb.hwvtepsouthbound.transact.DependencyQueue;
-import org.opendaylight.ovsdb.hwvtepsouthbound.transact.DependentJob;
-import org.opendaylight.ovsdb.hwvtepsouthbound.transact.HwvtepOperationalState;
-import org.opendaylight.ovsdb.hwvtepsouthbound.transact.McastMacsRemoteUpdateCommand;
-import org.opendaylight.ovsdb.hwvtepsouthbound.transact.UnMetDependencyGetter;
+import org.opendaylight.ovsdb.hwvtepsouthbound.DataChangeListenerTestBase;
+import org.opendaylight.ovsdb.hwvtepsouthbound.SameThreadScheduledExecutor;
+import org.opendaylight.ovsdb.hwvtepsouthbound.TestBuilders;
import org.opendaylight.ovsdb.lib.notation.UUID;
import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
import org.opendaylight.yangtools.yang.binding.Identifiable;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.powermock.reflect.Whitebox;
@RunWith(MockitoJUnitRunner.Silent.class)
public class DependencyQueueTest extends DataChangeListenerTestBase {
Map<Class<? extends Identifiable>, List<InstanceIdentifier>> unMetDependencies;
void setupForTest() throws Exception {
- mcastMacDataValidator = Whitebox.getInternalState(McastMacsRemoteUpdateCommand.class,
- UnMetDependencyGetter.class);
+ mcastMacDataValidator = McastMacsRemoteUpdateCommand.MCAST_MAC_DATA_VALIDATOR;
opState = new HwvtepOperationalState(connectionInstance);
mac = TestBuilders.buildRemoteMcastMacs(nodeIid,"FF:FF:FF:FF:FF:FF", "ls0",
new String[]{"192.168.122.20", "192.168.122.30"});
* 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.ovsdb.hwvtepsouthbound;
+package org.opendaylight.ovsdb.hwvtepsouthbound.transact;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
-import org.opendaylight.ovsdb.hwvtepsouthbound.transact.HwvtepOperationalState;
-import org.opendaylight.ovsdb.hwvtepsouthbound.transact.McastMacsRemoteUpdateCommand;
-import org.opendaylight.ovsdb.hwvtepsouthbound.transact.UnMetDependencyGetter;
+import org.opendaylight.ovsdb.hwvtepsouthbound.DataChangeListenerTestBase;
+import org.opendaylight.ovsdb.hwvtepsouthbound.TestBuilders;
import org.opendaylight.ovsdb.lib.notation.UUID;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepNodeName;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
import org.opendaylight.yangtools.yang.binding.Identifiable;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.powermock.reflect.Whitebox;
@RunWith(MockitoJUnitRunner.Silent.class)
public class UnMetDependencyGetterTest extends DataChangeListenerTestBase {
Map<Class<? extends Identifiable>, List<InstanceIdentifier>> unMetDependencies;
void setupForTest() {
- mcastMacDataValidator =
- Whitebox.getInternalState(McastMacsRemoteUpdateCommand.class, UnMetDependencyGetter.class);
+ mcastMacDataValidator = McastMacsRemoteUpdateCommand.MCAST_MAC_DATA_VALIDATOR;
opState = new HwvtepOperationalState(connectionInstance);
mac = TestBuilders.buildRemoteMcastMacs(nodeIid, "FF:FF:FF:FF:FF:FF", "ls0",
new String[] {"192.168.122.20", "192.168.122.30"});