GetDefinitions { public Map<MatchItemName, MatchItemDefinition> getMatchItemDefinition(){ fetchMatchItemDefinitions(); Map<MatchItemName, MatchItemDefinition> map = new HashMap<MatchItemName, MatchItemDefinition>(); if (matchItemDefinitionList != null){ for (MatchItemDefinition matchItemDefinition : matchItemDefinitionList){ map.put(matchItemDefinition.getMatchItemName(),matchItemDefinition); } } 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 testGetMatchItemDefinition() throws Exception { Map<MatchItemName, MatchItemDefinition> map1 = new HashMap<MatchItemName, MatchItemDefinition>(); MatchItemName matchItemName = mock(MatchItemName.class); MatchItemDefinition matchItemDefinition = mock(MatchItemDefinition.class); map1.put(matchItemName, matchItemDefinition); List<MatchItemDefinition> matchItemDefinitionList = new ArrayList<MatchItemDefinition>(); matchItemDefinitionList.add(matchItemDefinition); Class<GetDefinitions> class_1 = GetDefinitions.class; Field field = class_1.getDeclaredField("matchItemDefinitionList"); field.setAccessible(true); field.set(getDefinitions, matchItemDefinitionList); CheckedFuture matchitemdefinitionFuture = mock(CheckedFuture.class); ReadOnlyTransaction readOnlyTransaction = mock(ReadOnlyTransaction.class); when(dataBroker.newReadOnlyTransaction()).thenReturn(readOnlyTransaction); when(readOnlyTransaction.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class))).thenReturn(matchitemdefinitionFuture); when(matchItemDefinition.getMatchItemName()).thenReturn(matchItemName); Assert.assertEquals(getDefinitions.getMatchItemDefinition(), map1); }