GetDefinitions { public Map<ConnectionType, ConnectionDefinition> getConnectionDefinition(){ fetchConnectionDefinitionList(); Map<ConnectionType, ConnectionDefinition> map = new HashMap<ConnectionType, ConnectionDefinition>(); if (connectionDefinitionsList != null){ for (ConnectionDefinition connectionDefinition : connectionDefinitionsList){ map.put(connectionDefinition.getConnectionType(),connectionDefinition); } } 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 testGetConnectionDefinition() throws Exception { Map<ConnectionType, ConnectionDefinition> map1 = new HashMap<ConnectionType, ConnectionDefinition>(); ConnectionType connectionType = mock(ConnectionType.class); ConnectionDefinition connectionDefinition = mock(ConnectionDefinition.class); map1.put(connectionType,connectionDefinition); List<ConnectionDefinition> connectionDefinitionList = new ArrayList<ConnectionDefinition>(); connectionDefinitionList.add(connectionDefinition); Class<GetDefinitions> class_1 = GetDefinitions.class; Field field = class_1.getDeclaredField("connectionDefinitionsList"); field.setAccessible(true); field.set(getDefinitions, connectionDefinitionList); CheckedFuture connectiondefinitionFuture = mock(CheckedFuture.class); ReadOnlyTransaction readOnlyTransaction = mock(ReadOnlyTransaction.class); when(dataBroker.newReadOnlyTransaction()).thenReturn(readOnlyTransaction); when(readOnlyTransaction.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class))).thenReturn(connectiondefinitionFuture); when(connectionDefinition.getConnectionType()).thenReturn(connectionType); Assert.assertEquals(getDefinitions.getConnectionDefinition(), map1); }