本文整理汇总了Java中org.apache.commons.collections4.multimap.ArrayListValuedHashMap类的典型用法代码示例。如果您正苦于以下问题:Java ArrayListValuedHashMap类的具体用法?Java ArrayListValuedHashMap怎么用?Java ArrayListValuedHashMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ArrayListValuedHashMap类属于org.apache.commons.collections4.multimap包,在下文中一共展示了ArrayListValuedHashMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; //导入依赖的package包/类
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"));
}
示例2: matchTestCaseFailures
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; //导入依赖的package包/类
/**
* 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);
}
示例3: Should_Use_User_Constructor_Parameters
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; //导入依赖的package包/类
@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);
}
示例4: Should_Create_Constructor_Parameters_When_Parameters_Are_Not_Provided
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; //导入依赖的package包/类
@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);
}
示例5: Should_Create_Constructor_Parameters_When_Could_Not_Find_Matching_Constructor_Parameters_Types
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; //导入依赖的package包/类
@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();
}
示例6: Should_Create_Object_With_User_Defined_Constructor_Parameters
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; //导入依赖的package包/类
@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);
}
示例7: Should_Create_Object_Using_User_Parameters
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; //导入依赖的package包/类
@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);
}
示例8: processMqscFiles
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; //导入依赖的package包/类
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);
}
}
}
}
示例9: parseBody
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; //导入依赖的package包/类
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;
}
示例10: sortByRecipients
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; //导入依赖的package包/类
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;
}
示例11: setSegments
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; //导入依赖的package包/类
/**
* 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;
}
示例12: OSMData
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; //导入依赖的package包/类
/**
* 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;
}
示例13: setEntities
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; //导入依赖的package包/类
/**
* 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;
}
示例14: Should_Create_New_Object_Generator_When_User_Defined_Class_And_Constructor
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; //导入依赖的package包/类
@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);
}
示例15: Should_Return_Expected_Collection_Object
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; //导入依赖的package包/类
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);
};
}