public static void main(String[] args) { MultiValuedMap<String, String> map = new ArrayListValuedHashMap<>(); map.put("one", "A"); System.out.println(map); map.putAll("one", Arrays.asList("B", "C")); System.out.println(map); map.put("one", "D"); System.out.println(map); map.putAll("two", Arrays.asList("1", "2", "3")); System.out.println(map); System.out.printf("The value of the one key: %s\n", map.get("one")); }
/** * Matches the @searchedText in each test failure for a test and return a list with the Jenkins links to the failed tests reports * * @param failureNodes the xml failure/error nodes for a test case element * @param testUrl the test url * @param buildNumber build number * @param nodeUrl node URL * @param toolArgs: toolArgs.searchInJUnitReports true if we search a regular expression in failure messages * toolArgs.groupTestsFailures true if it groups failures based on stacktrace and failure message * toolArgs.searchedText the regular expression to match with the failure message * @return a list with the Jenkins links to the failed tests reports */ private static FailuresMatchResult matchTestCaseFailures(NodeList failureNodes, String testUrl, String testName, String shortTestName, String buildNumber, String nodeUrl, ToolArgs toolArgs) { List<String> matchedFailedTests = new ArrayList<>(); ArrayListValuedHashMap<String, TestFailure> testsFailures = new ArrayListValuedHashMap<>(); if (failureNodes.getLength() > 0 && toolArgs.stableReport != null) { if (toolArgs.stableReport && !toolArgs.stabilityListParser.getStableTests().contains(testName) && toolArgs.stabilityListParser.getUnstableTests().contains(testName) || !toolArgs.stableReport && !toolArgs.stabilityListParser.getUnstableTests().contains(testName) && toolArgs.stabilityListParser.getStableTests().contains(testName)) { return new FailuresMatchResult(matchedFailedTests, testsFailures, null); } } for (int failureNodeIndex = 0; failureNodeIndex < failureNodes.getLength(); failureNodeIndex++) { Element failureElement = (Element) failureNodes.item(failureNodeIndex); String message = failureElement.getAttribute("message"); if (toolArgs.searchInJUnitReports && Main.findSearchedTextInContent(toolArgs.searchedText, message)) { matchedFailedTests.add(testUrl); } if (toolArgs.groupTestsFailures || toolArgs.showTestsDifferences) { String stacktrace = failureElement.getTextContent(); stacktrace = getFirstXLines(stacktrace, 2); stacktrace = stacktrace.trim().isEmpty() ? stacktrace : stacktrace.concat(": "); String failureToCompare = stacktrace.concat(getFirstXLines(message, 1)); testsFailures.put(testUrl, new TestFailure(buildNumber, nodeUrl, buildTestReportLink(nodeUrl, testUrl), testName, shortTestName, failureToCompare, failureToCompare.length() >= 200 ? failureToCompare.substring(0, 200) + " ..." : failureToCompare)); } } return new FailuresMatchResult(matchedFailedTests, testsFailures, null); }
@Test void Should_Use_User_Constructor_Parameters() { // given final Class[] classesToTest = { ClassWithSyntheticConstructor.class }; final ConstructorParameters parameters = new ConstructorParameters(new Object[]{ "string" }, new Class[]{ String.class }); final MultiValuedMap<Class<?>, ConstructorParameters> constructorParameters = spy(new ArrayListValuedHashMap<>()); constructorParameters.put(ClassWithSyntheticConstructor.class, parameters); final ConstructorTester constructorTester = new ConstructorTester(); constructorTester.setUserDefinedConstructors(constructorParameters); // when final Throwable result = catchThrowable(() -> constructorTester.testAll(classesToTest)); // then assertThat(result).isNull(); verify(constructorParameters).get(ClassWithSyntheticConstructor.class); }
@Test void Should_Create_Constructor_Parameters_When_Parameters_Are_Not_Provided() { // given final Class[] classesToTest = { ClassWithSyntheticConstructor.class }; final MultiValuedMap<Class<?>, ConstructorParameters> constructorParameters = spy(new ArrayListValuedHashMap<>()); final ConstructorTester constructorTester = new ConstructorTester(); constructorTester.setUserDefinedConstructors(constructorParameters); // when final Throwable result = catchThrowable(() -> constructorTester.testAll(classesToTest)); // then assertThat(result).isNull(); verify(constructorParameters, never()).get(ClassWithSyntheticConstructor.class); }
@Test void Should_Create_Constructor_Parameters_When_Could_Not_Find_Matching_Constructor_Parameters_Types() { // given final Class[] classesToTest = { ClassWithSyntheticConstructor.class }; final ConstructorParameters parameters = spy(new ConstructorParameters(new Object[]{ "to", "many", "parameters" }, new Class[]{ String.class, String.class, String.class })); final MultiValuedMap<Class<?>, ConstructorParameters> constructorParameters = spy(new ArrayListValuedHashMap<>()); constructorParameters.put(ClassWithSyntheticConstructor.class, parameters); final ConstructorTester constructorTester = new ConstructorTester(); constructorTester.setUserDefinedConstructors(constructorParameters); // when final Throwable result = catchThrowable(() -> constructorTester.testAll(classesToTest)); // then assertThat(result).isNull(); verify(parameters, never()).getParameters(); }
@Test void Should_Create_Object_With_User_Defined_Constructor_Parameters() { // given final ArrayListValuedHashMap<Class<?>, ConstructorParameters> constructorParameters = new ArrayListValuedHashMap<>(); final ConstructorParameters parameters = new ConstructorParameters(new Object[]{"expectedString"}, new Class[]{Object.class}); constructorParameters.put(NoDefaultConstructor.class, parameters); final BestConstructorInstantiator instantiator = new BestConstructorInstantiator(NoDefaultConstructor.class, constructorParameters); final NoDefaultConstructor expectedResult = new NoDefaultConstructor("expectedString"); // when final Object result = instantiator.instantiate(); // then assertThat(result).isEqualTo(expectedResult); }
@Test void Should_Create_Object_Using_User_Parameters() { // given final ArrayListValuedHashMap<Class<?>, ConstructorParameters> constructorParameters = new ArrayListValuedHashMap<>(); final Class<?> clazz = A.class; constructorParameters.put(clazz, new ConstructorParameters(new Object[]{ 12345 }, new Class[]{ int.class })); final AbstractMultiConstructorInstantiator instantiator = new MockMultiConstructorInstantiator(clazz, constructorParameters); final A expectedResult = new A(12345); // when final Object result = instantiator.instantiateUsingUserParameters(); // then assertThat(result).isEqualTo(expectedResult); }
private void processMqscFiles(XMLConfiguration config, List<File> mqscFiles, String releaseFolder) { if(CollectionUtils.isNotEmpty(mqscFiles)){ List<ConfigurationNode> allMQSCEnvironments = config.getRootNode().getChildren(); if(CollectionUtils.isNotEmpty(allMQSCEnvironments)){ MultiValuedMap<String,String> allMQSCForEnvironment = new ArrayListValuedHashMap<>(); processMQSCForAllEnvironments(config, mqscFiles, allMQSCEnvironments, allMQSCForEnvironment); for(String key: allMQSCForEnvironment.keySet()){ List<String> mqscContentList = (List<String>)allMQSCForEnvironment.get(key); generateMQSCContent(config, mqscContentList, key, releaseFolder); } } } }
public static RequestBody parseBody(byte[] body, RequestHeader header) { if (body.length == 0) { return new RequestBody(); } String contentType = header.getContentType(); Map<String, MimeData> mimeMap = Collections.emptyMap(); MultiValuedMap<String, String> formMap = new ArrayListValuedHashMap<>(); if (contentType.contains("application/x-www-form-urlencoded")) { try { String bodyMsg = new String(body, "utf-8"); RequestParser.parseParameters(bodyMsg, formMap); } catch (UnsupportedEncodingException ignored) { } } else if (contentType.contains("multipart/form-data")) { int boundaryValueIndex = contentType.indexOf("boundary="); String bouStr = contentType.substring(boundaryValueIndex + 9); // 9是 `boundary=` 长度 mimeMap = parseFormData(body, bouStr); } RequestBody requestBody = new RequestBody(); requestBody.setFormMap(formMap); requestBody.setMimeMap(mimeMap); return requestBody; }
private ArrayListValuedHashMap<String, Message> sortByRecipients(Collection<Message> messages) { ArrayListValuedHashMap<String, Message> rv = new ArrayListValuedHashMap<>(); messages.forEach(m -> m.getTo().forEach( to -> rv.put(to, m))); return rv; }
/** * Sets the {@code WaySegment}s. * * @param edgeSegments * a collection of way segments to store */ public void setSegments(Collection<WaySegment> edgeSegments) { MultiValuedMap<WaySegmentId, WaySegment> res = new ArrayListValuedHashMap<>(); for (WaySegment segment : edgeSegments) { res.put(segment.getId(), segment); } this.segments = res; }
/** * Creates an new instance of {@code OSMData} of a {@link Set} of * {@link Entity}s. * * @param entities * set of {@code Entity}s to store */ public OSMData(Set<Entity> entities) { this.boundingBox = null; MultiValuedMap<Long, Entity> map = new ArrayListValuedHashMap<>(); for (Entity e : entities) { if (e instanceof Bound) this.boundingBox = (Bound) e; map.put(e.getId(), e); } this.entities = map; }
/** * Sets the entities * * @param entities */ protected void setEntities(Set<Entity> entities) { MultiValuedMap<Long, Entity> map = new ArrayListValuedHashMap<>(); for (Entity e : entities) { map.put(e.getId(), e); } this.entities = map; }
@Test void Should_Create_New_Object_Generator_When_User_Defined_Class_And_Constructor() { // given final AbstractTester abstractTester = new AbstractTesterImplementation(); final ObjectGenerator beforeChange = abstractTester.objectGenerator; // when abstractTester.setUserDefinedConstructors(new ArrayListValuedHashMap<>()); final ObjectGenerator afterChange = abstractTester.objectGenerator; // then assertThat(beforeChange).isNotEqualTo(afterChange); }
private Executable Should_Return_Expected_Collection_Object(final Class<?> classToInstantiate) { return () -> { // given final CollectionInstantiator instantiator = new CollectionInstantiator(classToInstantiate, new ArrayListValuedHashMap<>()); // when final Object result = instantiator.instantiate(); // then assertThat(result).isInstanceOf(classToInstantiate); }; }
@Test void Should_Throws_Exception_When_Prepared_Objects_Do_Not_Contain_Expected_Class() { // given final CollectionInstantiator instantiator = new CollectionInstantiator(String.class, new ArrayListValuedHashMap<>()); // when final Throwable result = catchThrowable(instantiator::instantiate); // then assertThat(result).isInstanceOf(ObjectInstantiationException.class); }
@Test void Should_Return_Null_When_Enum_Is_Empty() { // given final EnumInstantiator instantiator = new EnumInstantiator(EmptyEnum.class, new ArrayListValuedHashMap<>()); // when final Object result = instantiator.instantiate(); // then assertThat(result).isNull(); }
@Test void Should_Return_Any_Enum_Value() { // given final Class<?> doubleEnumClass = DoubleEnum.class; final EnumInstantiator instantiator = new EnumInstantiator(doubleEnumClass, new ArrayListValuedHashMap<>()); // when final Object result = instantiator.instantiate(); // then assertThat(result).isInstanceOf(doubleEnumClass); }
@Test void Should_Return_One_Enum_Value() { // given final Class<?> oneEnumClass = OneEnum.class; final EnumInstantiator instantiator = new EnumInstantiator(oneEnumClass, new ArrayListValuedHashMap<>()); // when final Object result = instantiator.instantiate(); // then assertThat(result).isInstanceOf(oneEnumClass); }
private Executable Should_Instantiate_Primitive(final Class<?> classToInstantiate) { return () -> { // given final JavaTypeInstantiator instantiator = new JavaTypeInstantiator(classToInstantiate, new ArrayListValuedHashMap<>()); // when final Object result = instantiator.instantiate(); // then assertThat(result).isNotNull(); }; }
private Executable Should_Instantiate_Java_Type_Classes(final Class<?> classToInstantiate) { return () -> { // given final JavaTypeInstantiator instantiator = new JavaTypeInstantiator(classToInstantiate, new ArrayListValuedHashMap<>()); // when final Object result = instantiator.instantiate(); // then assertThat(result).isInstanceOf(classToInstantiate) .isNotNull(); }; }
@Test void Should_Create_Object_Using_Default_Constructor() { // given final Class<String> classToInstantiate = String.class; final DefaultConstructorInstantiator instantiator = new DefaultConstructorInstantiator(classToInstantiate, new ArrayListValuedHashMap<>()); // when final Object result = instantiator.instantiate(); // then assertThat(result).isInstanceOf(classToInstantiate); }
@Test void Should_Throw_Exception_When_Cannot_Instantiate_Object() { // given final Class<?> classToInstantiate = No_Args_Constructor_Throws_IllegalAccessException.class; final DefaultConstructorInstantiator instantiator = new DefaultConstructorInstantiator(classToInstantiate, new ArrayListValuedHashMap<>()); // when final Throwable result = catchThrowable(instantiator::instantiate); // then assertThat(result).isInstanceOf(ObjectInstantiationException.class); }
@Test void Should_Instantiate_Two_Classes() { // given final Class[] classesToInstantiate = { A.class, B.class }; // when final Object[] result = Instantiable.instantiateClasses(classesToInstantiate, new ArrayListValuedHashMap<>()); // then assertThat(result).extracting(Object::getClass) .containsExactlyInAnyOrder(classesToInstantiate); }
@Test void Should_Return_User_Defined_Constructor_Instantiator_If_Class_Does_Not_Qualifies_For_Proxy_And() { // given final ArrayListValuedHashMap<Class<?>, ConstructorParameters> constructorParameters = new ArrayListValuedHashMap<>(); final Class<?> clazz = A.class; constructorParameters.put(clazz, new ConstructorParameters(new Object[0], new Class[0])); // when final AbstractObjectInstantiator result = Instantiable.forClass(clazz, constructorParameters); // then assertThat(result).isInstanceOf(UserDefinedConstructorInstantiator.class); }
@Test void Should_Return_Proxy_Instantiator_If_Class_Qualifies_For_Proxy_And_User_Defined_Constructor_Parameters() { // given final ArrayListValuedHashMap<Class<?>, ConstructorParameters> constructorParameters = new ArrayListValuedHashMap<>(); final Class<?> clazz = Abstract.class; constructorParameters.put(clazz, new ConstructorParameters(new Object[0], new Class[0])); // when final AbstractObjectInstantiator result = Instantiable.forClass(clazz, constructorParameters); // then assertThat(result).isInstanceOf(ProxyInstantiator.class); }
private Executable Should_Create_Array(final Class<?> classToInstantiate) { return () -> { // given final ArrayInstantiator instantiator = new ArrayInstantiator(classToInstantiate, new ArrayListValuedHashMap<>()); // when final Object result = instantiator.instantiate(); // then assertThat(result).isInstanceOf(classToInstantiate); }; }
@Test void Should_Return_Null_If_Parameters_For_This_Class_Are_Empty() { // given final ArrayListValuedHashMap<Class<?>, ConstructorParameters> constructorParameters = new ArrayListValuedHashMap<>(); final Class<?> clazz = A.class; final AbstractMultiConstructorInstantiator instantiator = new MockMultiConstructorInstantiator(clazz, constructorParameters); // when final Object result = instantiator.instantiateUsingUserParameters(); // then assertThat(result).isNull(); }
@Test void Should_Throw_Exception_If_Constructor_Throws_Exception() { // given final ArrayListValuedHashMap<Class<?>, ConstructorParameters> constructorParameters = new ArrayListValuedHashMap<>(); final Class<?> clazz = B.class; final AbstractMultiConstructorInstantiator instantiator = new MockMultiConstructorInstantiator(clazz, constructorParameters); final Throwable expectedResult = new ObjectInstantiationException(B.class, "msg", null); // when final Throwable result = catchThrowable(instantiator::createFindingBestConstructor); // then assertThat(result).isEqualToComparingFieldByField(expectedResult); }
private static RequestHeader parseHeader(byte[] head) throws IOException { RequestHeader header = new RequestHeader(); try (BufferedReader reader = new BufferedReader(new StringReader(new String(head, "UTF-8")))) { Map<String, String> headMap = new HashMap<>(); String line = reader.readLine(); String[] lineOne = line.split("\\s"); String path = URLDecoder.decode(lineOne[1], "utf-8"); String method = lineOne[0]; HttpScheme scheme = HttpScheme.parseScheme(lineOne[2]); while ((line = reader.readLine()) != null) { String[] keyValue = line.split(":", 2); headMap.put(keyValue[0].trim().toLowerCase(), keyValue[1].trim()); } int index = path.indexOf('?'); MultiValuedMap<String, String> queryMap = new ArrayListValuedHashMap<>(); String queryString = StringUtils.EMPTY; if (index != -1) { queryString = path.substring(index + 1); RequestParser.parseParameters(queryString, queryMap); path = path.substring(0, index); } header.setURI(path); // 大小写敏感 header.setMethod(method); // 大小写敏感 header.setHead(headMap); header.setQueryString(queryString); header.setQueryMap(queryMap); header.setCookies(parseCookie(headMap)); header.setScheme(scheme); return header; } }
private ListValuedMap<Long, String> calculateServiceHealth(ListValuedMap<Long, String> serviceStates, Metadata metadata) { ListValuedMap<Long, String> stackState = new ArrayListValuedHashMap<>(); for (ServiceInfo serviceInfo : metadata.getServices()) { Long stackId = serviceInfo.getStackId(); List<String> healthStates = serviceStates.get(serviceInfo.getId()); if (healthStates == null) { healthStates = new ArrayList<>(); } if (SUPPORTED_SERVICE_KINDS.contains(serviceInfo.getKind())) { // Haven't met the scale yet boolean scaleNotMet = !serviceInfo.isGlobal() && serviceInfo.getScale() != null && healthStates.size() != (serviceInfo.getScale() * (1 + serviceInfo.getSidekicks().size())); if (healthStates.isEmpty() || scaleNotMet) { healthStates = Collections.singletonList(HEALTH_STATE_DEGRADED); } } else { healthStates = Collections.singletonList(null); } String serviceState = aggregate(healthStates); if (!Objects.equals(serviceState, serviceInfo.getHealthState())) { writeServiceHealthState(metadata, serviceInfo.getId(), serviceState); } stackState.put(stackId, serviceState); } return stackState; }
@Override public Map<Long, Collection<MountEntry>> getMountsForInstances(List<Long> ids, final IdFormatter idF) { ListValuedMap<Long, MountEntry> result = new ArrayListValuedHashMap<>(); create().select(INSTANCE.NAME, VOLUME.NAME, VOLUME.ID, MOUNT.PERMISSIONS, MOUNT.PATH, MOUNT.INSTANCE_ID) .from(MOUNT) .join(VOLUME) .on(VOLUME.ID.eq(MOUNT.VOLUME_ID)) .join(INSTANCE) .on(INSTANCE.ID.eq(MOUNT.INSTANCE_ID)) .where(MOUNT.REMOVED.isNull() .and(VOLUME.REMOVED.isNull()) .and(MOUNT.INSTANCE_ID.in(ids))) .fetchInto((RecordHandler<Record6<String, String, Long, String, String, Long>>) record -> { Long instanceId = record.getValue(MOUNT.INSTANCE_ID); MountEntry mount = new MountEntry(); mount.setInstanceName(record.getValue(INSTANCE.NAME)); mount.setInstanceId(idF.formatId(InstanceConstants.TYPE, instanceId)); mount.setPath(record.getValue(MOUNT.PATH)); mount.setPermission(record.getValue(MOUNT.PERMISSIONS)); mount.setVolumeId(idF.formatId(VolumeConstants.TYPE, record.getValue(VOLUME.ID))); mount.setVolumeName(record.getValue(VOLUME.NAME)); result.put(instanceId, mount); }); return result.asMap(); }
@Override public Map<Long, Collection<MountEntry>> getMountsForVolumes(List<Long> ids, final IdFormatter idF) { ListValuedMap<Long, MountEntry> result = new ArrayListValuedHashMap<>(); create().select(VOLUME.NAME, MOUNT.PERMISSIONS, MOUNT.PATH, MOUNT.INSTANCE_ID, MOUNT.VOLUME_ID, INSTANCE.NAME) .from(MOUNT) .join(INSTANCE) .on(INSTANCE.ID.eq(MOUNT.INSTANCE_ID)) .join(VOLUME) .on(VOLUME.ID.eq(MOUNT.VOLUME_ID)) .where(INSTANCE.REMOVED.isNull() .and(VOLUME.REMOVED.isNull()) .and(MOUNT.VOLUME_ID.in(ids))) .fetchInto((RecordHandler<Record6<String, String, String, Long, Long, String>>) record -> { Long volumeId = record.getValue(MOUNT.VOLUME_ID); MountEntry mount = new MountEntry(); mount.setInstanceName(record.getValue(INSTANCE.NAME)); mount.setInstanceId(idF.formatId(InstanceConstants.TYPE, record.getValue(MOUNT.INSTANCE_ID))); mount.setPath(record.getValue(MOUNT.PATH)); mount.setPermission(record.getValue(MOUNT.PERMISSIONS)); mount.setVolumeId(idF.formatId(VolumeConstants.TYPE, volumeId)); mount.setVolumeName(record.getValue(VOLUME.NAME)); result.put(volumeId, mount); }); return result.asMap(); }
/** * Matches the @searchedText in each test failure and return a list with the Jenkins links to the failed tests reports * * @param jUnitReportXml the JUnit xml report as a String * @param buildNumber build number * @param nodeUrl node URL * @param toolArgs: toolArgs.searchInJUnitReports true if we search a regular expression in failure messages * toolArgs.groupTestsFailures true if it groups failures based on stacktrace and failure message * toolArgs.searchedText the regular expression to match with the failure message * @return a list with the Jenkins links to the failed tests reports * @throws ParserConfigurationException * @throws IOException * @throws SAXException */ static FailuresMatchResult matchJUnitReportFailures(String jUnitReportXml, String buildNumber, String nodeUrl, ToolArgs toolArgs) throws ParserConfigurationException, IOException, SAXException { List<String> matchedFailedTests = new ArrayList<>(); Map<String, Integer> testsCount = new HashedMap<>(); ArrayListValuedHashMap<String, TestFailure> testsFailures = new ArrayListValuedHashMap<>(); ArrayListValuedHashMap<String, TestStatus> testsStatus = new ArrayListValuedHashMap<>(); // if the JUnit report is empty we cannot parse it if (jUnitReportXml.isEmpty()) { return new FailuresMatchResult(matchedFailedTests, testsFailures, testsStatus); } DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); jUnitReportXml = encodeNewLineCharInFailureElements(jUnitReportXml); Document doc = dBuilder.parse(new ByteArrayInputStream(jUnitReportXml.getBytes())); doc.getDocumentElement().normalize(); NodeList testCasesList = doc.getElementsByTagName("testcase"); for (int testCaseIndex = 0; testCaseIndex < testCasesList.getLength(); testCaseIndex++) { Node testCaseNode = testCasesList.item(testCaseIndex); if (testCaseNode.getNodeType() == Node.ELEMENT_NODE) { Element testCaseElement = (Element) testCaseNode; String shortTestName = testCaseElement.getAttribute("name"); String testName = testCaseElement.getAttribute("classname").concat(".").concat(shortTestName); String[] classNameTokens = testCaseElement.getAttribute("classname").split("\\."); // the package name from url needs to remain with ".", the class name is delimited using "/" String packageName = ""; for (int i = 0; i < classNameTokens.length - 1; i++) { packageName += classNameTokens[i].concat("."); } packageName = packageName.length() > 0 ? new StringBuilder(packageName).deleteCharAt(packageName.length() - 1).toString() : packageName; packageName = classNameTokens.length < 2 ? "(root)" : packageName; String className = classNameTokens[classNameTokens.length - 1]; String testUrl = packageName.concat("/").concat(className).concat("/").concat(shortTestName.replaceAll("[.: \\\\()\\[\\]/,-]", "_")); Integer testCount = testsCount.get(testUrl); testCount = testCount == null ? 0 : testCount; testsCount.put(testUrl, ++testCount); testUrl = testCount < 2 ? testUrl : testUrl.concat("_").concat(String.valueOf(testCount)); NodeList failureNodes = testCaseElement.getElementsByTagName("failure"); FailuresMatchResult failuresMatchResult = matchTestCaseFailures(failureNodes, testUrl, testName, shortTestName, buildNumber, nodeUrl, toolArgs); matchedFailedTests.addAll(failuresMatchResult.matchedFailedTests); testsFailures.putAll(failuresMatchResult.testsFailures); NodeList errorNodes = testCaseElement.getElementsByTagName("error"); FailuresMatchResult errorsMatchResult = matchTestCaseFailures(errorNodes, testUrl, testName, shortTestName, buildNumber, nodeUrl, toolArgs); matchedFailedTests.addAll(errorsMatchResult.matchedFailedTests); NodeList skippedNodes = testCaseElement.getElementsByTagName("skipped"); FailuresMatchResult skippedMatchResult = matchTestCaseFailures(skippedNodes, testUrl, testName, shortTestName, buildNumber, nodeUrl, toolArgs); matchedFailedTests.addAll(skippedMatchResult.matchedFailedTests); testsFailures.putAll(skippedMatchResult.testsFailures); if (toolArgs.computeStabilityList) { String stabilityTestName = testCaseElement.getAttribute("classname").concat("&").concat(shortTestName); Boolean failedStatus = failureNodes.getLength() != 0 || errorNodes.getLength() != 0; TestStatus testStatus = new TestStatus(Integer.parseInt(buildNumber), failedStatus); testsStatus.put(stabilityTestName, testStatus); } } } return new FailuresMatchResult(matchedFailedTests, testsFailures, testsStatus); }
FailuresMatchResult(List<String> matchedFailedTests, ArrayListValuedHashMap<String, TestFailure> testsFailures, ArrayListValuedHashMap<String, TestStatus> testsStatus) { this.matchedFailedTests = matchedFailedTests; this.testsFailures = testsFailures; this.testsStatus = testsStatus; }
/** * Parses the csv records provided as {@code CSVParser} object. * * @param csvParser * the csv records to parse * @return the parsed way segments * * @throws WaySegmentParserException * if an error occurred while parsing the record (e.g. a * required column is not set) * @throws NumberFormatException * if a number cannot be parsed * @throws UnsupportedTimeRangeException * if the {@code time_range} column cannot be parsed */ public WaySegments parseCSVRecords(CSVParser csvParser) { ArrayListValuedHashMap<WaySegmentId, WaySegment> res = new ArrayListValuedHashMap<>(); PeekingIterator<CSVRecord> iter = Iterators .peekingIterator(csvParser.iterator()); while (iter.hasNext()) { ArrayList<Double> dists = new ArrayList<>(); ArrayList<Double> tempDiffs = new ArrayList<>(); CSVRecord current = iter.next(); WaySegmentParser.ParsedRecord currentParsed = parseCsvRecord( current); dists.add(currentParsed.getDist()); tempDiffs.add(currentParsed.getTempDiff()); while (iter.hasNext() && currentParsed.hasSameId(parseCsvRecord(iter.peek()))) { WaySegmentParser.ParsedRecord parsed = parseCsvRecord( iter.next()); dists.add(parsed.getDist()); tempDiffs.add(parsed.getTempDiff()); } double[] distsArray = dists.stream() .mapToDouble(Double::doubleValue).toArray(); double[] tempDiffsArray = tempDiffs.stream() .mapToDouble(Double::doubleValue).toArray(); res.put(new WaySegmentId(currentParsed.getWayId(), currentParsed.getNodeIds()), new WaySegment(currentParsed.getWayId(), currentParsed.getNodeIds(), currentParsed.getTime(), distsArray, tempDiffsArray)); } return new WaySegments(res); }