IEMappingCacheServiceImpl implements IEMappingCacheService { @Override public void syncIEMappingCache(String family) { Set<String> families = new HashSet<>(); families.add(family); if (!m_informationElementService.isIECacheAvailable()) { families = retrieveAllFamilies(); } families.forEach(this::updateIEMapping); } IEMappingCacheServiceImpl(InformationElementService informationElementService, DeviceCacheServiceImpl deviceFamilyCacheService); @Override void syncIEMappingCache(String family);  }
@Test public void testSyncIEMappingCache() throws Exception { when(m_informationElementService.isIECacheAvailable()).thenReturn(false); String responseInStr = "<rpc message-id=\"1\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" + " <get>\n" + " <filter type=\"subtree\">\n" + " <baa-network-manager:network-manager xmlns:baa-network-manager=\"urn:bbf:yang:obbaa:network-manager\">\n" + " <device-adapters xmlns=\"urn:bbf:yang:obbaa:network-manager\">\n" + " <device-adapter>\n" + " <type/>\n" + " <model/>\n" + " <vendor/>\n" + " <interface-version/>\n" + " </device-adapter>\n" + " </device-adapters>\n" + " </baa-network-manager:network-manager>\n" + " </filter>\n" + " </get>\n" + "</rpc>"; NetConfResponse response = DocumentToPojoTransformer.getNetconfResponse(DocumentUtils.stringToDocument(responseInStr)); when(m_deviceFamilyCacheService.getNetConfResponse(any())).thenReturn(response); m_ieIdIdMappingCacheService.syncIEMappingCache(m_family); verify(m_informationElementService).isIECacheAvailable(); String requestInString = "<rpc message-id=\"1\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" + " <get>\n" + " <filter type=\"subtree\">\n" + " <baa-network-manager:network-manager xmlns:baa-network-manager=\"urn:bbf:yang:obbaa:network-manager\">\n" + " <device-adapters xmlns=\"urn:bbf:yang:obbaa:network-manager\">\n" + " <device-adapter>\n" + " <type/>\n" + " <model/>\n" + " <vendor/>\n" + " <interface-version/>\n" + " </device-adapter>\n" + " </device-adapters>\n" + " </baa-network-manager:network-manager>\n" + " </filter>\n" + " </get>\n" + "</rpc>\n"; ArgumentCaptor<AbstractNetconfRequest> captor = new ArgumentCaptor<>(); verify(m_deviceFamilyCacheService).getNetConfResponse(captor.capture()); assertEquals(requestInString, captor.getValue().requestToString()); }