2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.groupbasedpolicy.sxp_ise_adapter.impl.util;
11 import static org.opendaylight.groupbasedpolicy.sxp_ise_adapter.impl.IseResourceTestHelper.readLocalResource;
13 import com.google.common.collect.Iterables;
14 import java.io.IOException;
15 import java.util.Collection;
16 import java.util.HashMap;
18 import javax.xml.xpath.XPath;
19 import org.junit.Assert;
20 import org.junit.Before;
21 import org.junit.Test;
22 import org.junit.runner.RunWith;
23 import org.mockito.runners.MockitoJUnitRunner;
24 import org.w3c.dom.Node;
25 import org.w3c.dom.NodeList;
26 import org.xml.sax.InputSource;
29 * Test for {@link IseReplyUtil}.
31 @RunWith(MockitoJUnitRunner.class)
32 public class IseReplyUtilTest {
34 private final String iseReplyAllSgts;
37 public IseReplyUtilTest() throws IOException {
38 iseReplyAllSgts = readLocalResource("./rawIse-allSgts2.xml");
42 public void setUp() throws Exception {
43 xpath = IseReplyUtil.setupXpath();
47 public void filterNewResourcesByID() throws Exception {
48 final Map<String, Integer> uuidMap = new HashMap<>();
49 uuidMap.put("abc123", 42);
51 final InputSource inputSource = IseReplyUtil.createInputSource(iseReplyAllSgts);
52 final NodeList allSgtResourceNodes = IseReplyUtil.findAllSgtResourceNodes(xpath, inputSource);
54 final Collection<Node> filteredNodes = IseReplyUtil.filterNewResourcesByID(uuidMap, xpath, allSgtResourceNodes);
56 Assert.assertEquals(1, filteredNodes.size());
57 Assert.assertEquals("https://example.org:9060/ers/config/sgt/abc124", Iterables.getFirst(filteredNodes, null).getNodeValue());