Containerization feature of SO
[so.git] / bpmn / MSOCommonBPMN / src / test / groovy / org / onap / so / bpmn / common / scripts / utils / IgnoreNamedElementsDifferenceListener.groovy
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.bpmn.common.scripts.utils
22
23 import org.custommonkey.xmlunit.Difference
24 import org.custommonkey.xmlunit.DifferenceConstants
25 import org.custommonkey.xmlunit.DifferenceListener
26 import org.w3c.dom.Node
27
28 class IgnoreNamedElementsDifferenceListener implements DifferenceListener {
29     private Set<String> blackList = new HashSet<String>();
30
31     public IgnoreNamedElementsDifferenceListener(String ... ignoreTags) {
32         for (String name : ignoreTags) {
33             blackList.add(name);
34         }
35     }
36
37     public int differenceFound(Difference difference) {
38         if (difference.getId() == DifferenceConstants.TEXT_VALUE_ID) {
39             if (blackList.contains(difference.getControlNodeDetail().getNode().getParentNode().getNodeName())) {
40                 return DifferenceListener.RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;
41             }
42         }
43
44         return DifferenceListener.RETURN_ACCEPT_DIFFERENCE;
45     }
46
47
48     public void skippedComparison(Node node, Node node1) {
49
50     }
51 }