List of usage examples for org.apache.commons.collections MultiMap put
Object put(Object key, Object value);
From source file:org.mule.module.launcher.DefaultAppBloodhound.java
public DefaultAppBloodhound() { // defaults first parserRegistry.put("properties", new PropertiesDescriptorParser()); final Iterator<DescriptorParser> it = ServiceRegistry.lookupProviders(DescriptorParser.class); MultiMap overrides = new MultiValueMap(); while (it.hasNext()) { final DescriptorParser parser = it.next(); overrides.put(parser.getSupportedFormat(), parser); }/*from w w w .ja va2 s . co m*/ mergeParserOverrides(overrides); }
From source file:org.mule.module.launcher.DescriptorParserTestCase.java
@Test public void testOverridePreferred() throws Exception { DefaultAppBloodhound bh = new DefaultAppBloodhound(); MultiMap overrides = new MultiValueMap(); overrides.put("properties", new TestDescriptorParserDefault()); // test with default annotation values bh.mergeParserOverrides(overrides);/*from w w w.j a v a 2 s. c o m*/ assertEquals(1, bh.parserRegistry.size()); DescriptorParser result = bh.parserRegistry.get("properties"); assertNotNull(result); assertTrue("@Preferred implementation ignored", result instanceof TestDescriptorParserDefault); }
From source file:org.mule.module.launcher.DescriptorParserTestCase.java
@Test public void testBothPreferredWithWeight() throws Exception { DefaultAppBloodhound bh = new DefaultAppBloodhound(); MultiMap overrides = new MultiValueMap(); overrides.put("properties", new TestDescriptorParserDefault()); overrides.put("properties", new TestDescriptorParserPreferred()); // test with weigh attribute (we have 3 candidates now) bh.mergeParserOverrides(overrides);//from www . ja v a 2s. c o m assertEquals(1, bh.parserRegistry.size()); DescriptorParser result = bh.parserRegistry.get("properties"); assertNotNull(result); assertTrue("@Preferred implementation ignored", result instanceof TestDescriptorParserPreferred); }
From source file:org.mule.module.launcher.DescriptorParserTestCase.java
@Test public void testOverrideWithoutPreferred() throws Exception { DefaultAppBloodhound bh = new DefaultAppBloodhound(); MultiMap overrides = new MultiValueMap(); overrides.put("properties", new TestDescriptorParserNoAnnotation()); // test with weigh attribute (we have 3 candidates now) bh.mergeParserOverrides(overrides);/*from w ww .j a va2 s . c o m*/ assertEquals(1, bh.parserRegistry.size()); DescriptorParser result = bh.parserRegistry.get("properties"); assertNotNull(result); assertTrue("@Preferred implementation ignored", result instanceof TestDescriptorParserNoAnnotation); }
From source file:org.mule.module.launcher.DescriptorParserTestCase.java
@Test public void testMixedOverrides() throws Exception { DefaultAppBloodhound bh = new DefaultAppBloodhound(); MultiMap overrides = new MultiValueMap(); overrides.put("properties", new TestDescriptorParserNoAnnotation()); overrides.put("properties", new TestDescriptorParserDefault()); // test with weigh attribute (we have 3 candidates now) bh.mergeParserOverrides(overrides);//from w ww . j av a 2 s . co m assertEquals(1, bh.parserRegistry.size()); DescriptorParser result = bh.parserRegistry.get("properties"); assertNotNull(result); assertTrue("@Preferred implementation ignored", result instanceof TestDescriptorParserDefault); }
From source file:org.openmrs.PropertiesFileValidator.java
private MultiMap getAsPropertiesKeyValueMultiMap(List<String> fileLines) { MultiMap multiMap = new MultiValueMap(); for (String line : fileLines) { if (isCorectKeyValueLine(line)) { Map.Entry<String, String> tuple = extractKeyValue(line); multiMap.put(tuple.getKey(), tuple.getValue()); }/* ww w. j a va 2s . c o m*/ } return multiMap; }
From source file:org.squashtest.tm.service.internal.repository.hibernate.HibernateExecutionStepDao.java
@Override public MultiMap findStepExecutionsStatus(List<Long> testCaseIds, List<Long> testStepIds) { if (testStepIds.isEmpty()) { return new MultiValueMap(); }/* www . j a va 2 s . c o m*/ List<ExecutionStep> execSteps = new ArrayList<>(); for (Long tcId : testCaseIds) { Query q = currentSession().getNamedQuery("execution.findAllByTestCaseIdAndItIdOrderByRunDate"); q.setParameter("testCaseId", tcId, LongType.INSTANCE); List<Execution> execs = q.list(); if (!execs.isEmpty()) { execSteps.addAll(execs.get(0).getSteps()); } } MultiMap result = new MultiValueMap(); for (ExecutionStep executionStep : execSteps) { if (testStepIds.contains(executionStep.getReferencedTestStep().getId())) { result.put(executionStep.getReferencedTestStep().getId(), executionStep); } } return result; }
From source file:org.squashtest.tm.service.internal.repository.hibernate.HibernateIterationDao.java
@SuppressWarnings("unchecked") @Override//w ww.j a va 2s . com public MultiMap findVerifiedITPI(List<Long> tcIds, List<Long> iterationsIds) { if (tcIds.isEmpty()) { return new MultiValueMap(); } Query q = currentSession().getNamedQuery("iteration.findITPIByTestCaseGroupByStatus"); q.setParameterList("testCasesIds", tcIds, LongType.INSTANCE); q.setParameterList("iterationsIds", iterationsIds, LongType.INSTANCE); List<Object[]> itpis = q.list(); MultiMap result = new MultiValueMap(); for (Object[] itpi : itpis) { TestCaseExecutionStatus tcStatus = new TestCaseExecutionStatus((ExecutionStatus) itpi[0], (Long) itpi[1]); result.put(tcStatus.getTestCaseId(), tcStatus); } return result; }
From source file:org.squashtest.tm.service.internal.testautomation.AutomatedSuiteManagerServiceImpl.java
/** * * @see org.squashtest.tm.service.testautomation.AutomatedSuiteManagerService#sortByProject(org.squashtest.tm.domain.testautomation.AutomatedSuite) *///from w ww . ja va 2 s . co m @SuppressWarnings({ "rawtypes", "unchecked" }) @Override public Collection<TestAutomationProjectContent> sortByProject(AutomatedSuite suite) { // security handled by in the code List<AutomatedExecutionExtender> extenders = suite.getExecutionExtenders(); PermissionsUtils.checkPermission(permissionService, extenders, EXECUTE); // first sort them using a map MultiMap testsByProjects = new MultiValueMap(); for (AutomatedExecutionExtender extender : extenders) { if (extender.isProjectDisassociated()) { continue; } TestAutomationProject project = extender.getAutomatedProject(); AutomatedTest test = extender.getAutomatedTest(); testsByProjects.put(project, test); } // now make a friendly bean of it Collection<TestAutomationProjectContent> projectContents = new LinkedList<>(); Set<Entry> entries = testsByProjects.entrySet(); for (Entry e : entries) { TestAutomationProject project = (TestAutomationProject) e.getKey(); Collection<AutomatedTest> tests = (Collection) e.getValue(); TestAutomationConnector connector = connectorRegistry .getConnectorForKind(project.getServer().getKind()); boolean orderGuaranteed = connector.testListIsOrderGuaranteed(tests); projectContents.add(new TestAutomationProjectContent(project, tests, orderGuaranteed)); } return projectContents; }
From source file:org.squashtest.tm.web.internal.helper.JsTreeHelper.java
/** * Coerces an array of dom nodes ids (["#TestCase-10", "#TestCaseLibrary-20"]) into a map. The result maps entities * ids by their short class name ([TestCase: [10], TestCaseLibrary: [20]]). * /*from w ww. ja v a 2 s .c o m*/ * @param domNodesIds * @return */ public static MultiMap mapIdsByType(String[] domNodesIds) { MultiMap res = new MultiValueMap(); Pattern pattern = Pattern.compile("(\\w+)-(\\d+)"); for (String domNodeId : domNodesIds) { Matcher matcher = pattern.matcher(domNodeId); while (matcher.find()) { if (matcher.groupCount() == 2) { // extra cautious not to get a null group below String type = matcher.group(1); Long id = Long.valueOf(matcher.group(2)); // the regexp pattern res.put(type, id); } } } return res; }