GetDefinitions { public Map<ActionName, ActionDefinition> getActionDefinition(){ fetchActionDefinitions(); Map<ActionName,ActionDefinition> map = new HashMap<ActionName, ActionDefinition>(); if (actionDefinitionList!=null){ for (ActionDefinition actionDefinition : actionDefinitionList){ map.put(actionDefinition.getActionName(),actionDefinition); } } return map; } GetDefinitions(DataBroker dataBroker); Map<NodeType, NodeDefinition> getNodeDefinition(); Map<MatchItemName, MatchItemDefinition> getMatchItemDefinition(); Map<ConnectionType, ConnectionDefinition> getConnectionDefinition(); Map<ActionName, ActionDefinition> getActionDefinition(); Map<ParameterName, ConditionParameterDefinition> getConditionParameterDefinition(); Map<PhysicalHostName, PhysicalHost> getPhysicalHost();  }
@Test public void testGetActionDefinition() throws Exception { Map<ActionName,ActionDefinition> map1 = new HashMap<ActionName, ActionDefinition>(); ActionName actionName = mock(ActionName.class); ActionDefinition actionDefinition = mock(ActionDefinition.class); map1.put(actionName,actionDefinition); List<ActionDefinition> actionDefinitionList = new ArrayList<ActionDefinition>(); actionDefinitionList.add(actionDefinition); Class<GetDefinitions> class_1 = GetDefinitions.class; Field field = class_1.getDeclaredField("actionDefinitionList"); field.setAccessible(true); field.set(getDefinitions, actionDefinitionList); CheckedFuture actiondefinitionFuture = mock(CheckedFuture.class); ReadOnlyTransaction readOnlyTransaction = mock(ReadOnlyTransaction.class); when(dataBroker.newReadOnlyTransaction()).thenReturn(readOnlyTransaction); when(readOnlyTransaction.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class))).thenReturn(actiondefinitionFuture); when(actionDefinition.getActionName()).thenReturn(actionName); Assert.assertEquals(getDefinitions.getActionDefinition(), map1); }