1 /* 2 * Copyright (C) 2010-2014 Hamburg Sud and the contributors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.aludratest.service.edifactfile; 17 18 import javax.xml.namespace.QName; 19 import javax.xml.xpath.XPathConstants; 20 21 import org.aludratest.impl.log4testing.ElementName; 22 import org.aludratest.impl.log4testing.ElementType; 23 import org.aludratest.impl.log4testing.TechnicalArgument; 24 import org.aludratest.impl.log4testing.TechnicalLocator; 25 import org.aludratest.service.Condition; 26 import org.databene.edifatto.ComparisonSettings; 27 import org.databene.edifatto.compare.AggregateDiff; 28 import org.databene.edifatto.compare.ComparisonModel; 29 import org.databene.edifatto.model.Interchange; 30 import org.w3c.dom.Element; 31 32 /** 33 * Performs queries on EDIFACT or X12 interchanges and analyzes their differences. 34 * @author Volker Bergmann 35 */ 36 public interface EdifactFileCondition extends Condition { 37 38 /** 39 * Tells if a file exists at the given path. 40 * @param elementType 41 * @param elementName 42 * @param filePath the file path to query 43 * @return true if a file with the provided path exists, otherwise false 44 */ 45 boolean exists( 46 @ElementType String elementType, 47 @ElementName String elementName, 48 @TechnicalLocator String filePath); 49 50 /** 51 * Creates an XML representation of the interchange and performs an XPath query on it. 52 * @param elementType 53 * @param elementName 54 * @param interchange the interchange to query 55 * @param xpathQuery the XPath query to perform 56 * @param returnType determines the type of the returned object: 57 * {@link XPathConstants#STRING} for a single {@link java.lang.String}, 58 * {@link XPathConstants#NODE} for a single {@link org.w3c.dom.Element}, 59 * {@link XPathConstants#NODESET} for a {@link org.w3c.dom.NodeList} 60 * @return the query result 61 */ 62 Object queryXML( 63 @ElementType String elementType, 64 @ElementName String elementName, 65 Interchange interchange, 66 @TechnicalLocator String xpathQuery, 67 @TechnicalArgument QName returnType); 68 69 /** 70 * Finds out the differences between two EDIFACT or X12 interchanges, 71 * ignoring elements that match the XPath exclusion paths. 72 * @param elementType 73 * @param elementName 74 * @param expected the expected interchange data 75 * @param actual the actual interface data 76 * @param settings the {@link ComparisonSettings} to apply 77 * @param model 78 * @return an AggregateDiff that represent the differences 79 * between the interchanges */ 80 AggregateDiff diff( 81 @ElementType String elementType, 82 @ElementName String elementName, 83 Interchange expected, 84 Interchange actual, 85 @TechnicalArgument ComparisonSettings settings, 86 @TechnicalArgument ComparisonModel<Element> model); 87 88 }