List of usage examples for org.apache.commons.collections MultiMap put
Object put(Object key, Object value);
From source file:edu.uci.ics.jung.graph.impl.BipartiteGraph.java
/** * Adds all pairs (key, value) to the multimap from * the initial set keySet./*from www. jav a2 s. c o m*/ * @param set * @param hyperEdge */ private static void addAll(MultiMap mm, Set keyset, Object value) { for (Iterator iter = keyset.iterator(); iter.hasNext();) { Object key = iter.next(); mm.put(key, value); } }
From source file:net.jadler.stubbing.MutableStubResponseTest.java
@Test @SuppressWarnings("unchecked") public void setHeaderCaseInsensitive() { this.msr.addHeaders(HEADERS_MAP); this.msr.setHeaderCaseInsensitive("hEaDer2", "value2_2"); final MultiMap expected = new MultiValueMap(); expected.put("header1", "value1_1"); expected.put("hEaDer2", "value2_2"); expected.put("header3", "value3_1"); assertThat(this.msr.getHeaders(), is(expected)); }
From source file:net.jadler.stubbing.MutableStubResponseTest.java
@Test @SuppressWarnings("unchecked") public void addHeaders() { this.msr.addHeaders(HEADERS_MAP); final MultiMap additionalHeaders = new MultiValueMap(); additionalHeaders.put("header3", "value3_1"); this.msr.addHeaders(additionalHeaders); assertThat(this.msr.getHeaders().size(), is(3)); assertThat((Set<String>) this.msr.getHeaders().keySet(), containsInAnyOrder("header1", "header2", "header3")); }
From source file:net.jadler.stubbing.MutableStubResponseTest.java
@Test @SuppressWarnings("unchecked") public void addHeadersTwoValues() { this.msr.addHeaders(HEADERS_MAP); final MultiMap additionalHeaders = new MultiValueMap(); additionalHeaders.put("header2", "value2_2"); this.msr.addHeaders(additionalHeaders); assertThat(this.msr.getHeaders().size(), is(3)); assertThat((Set<String>) this.msr.getHeaders().keySet(), containsInAnyOrder("header1", "header2", "header3")); assertThat((Collection<String>) this.msr.getHeaders().get("header2"), containsInAnyOrder("value2_1", "value2_2")); }
From source file:fr.in2p3.cc.storage.treqs.persistence.mock.dao.MockConfigurationDAO.java
/** * Drive distribution per user.// ww w.j a v a 2 s .c om * <p> * <code> * id type...user1 user2 user3 user4 user5 user6 user7<br/> * 1. T10K-A . 2 ... 1 ... 1 ... - ... - ... 2 ... 3<br/> * 2. T10K-B . 3 ... 2 ... - ... 1 ... - ... - ... 1<br/> * 3. T10K-C . - ... - ... - ... - ... 1 ... 1 ... 2 * </code> * * @see fr.in2p3.cc.storage.treqs.model.dao.ConfigurationDAO# * getResourceAllocation() * @return Allocation per mock users. * @throws AbstractPersistanceException * Never. */ @Override public MultiMap getResourceAllocation() throws AbstractPersistanceException { LOGGER.trace("> getResourceAllocation"); if (exception != null) { final AbstractPersistanceException toThrow = exception; exception = null; throw toThrow; } final MultiMap values = new MultiValueMap(); // T10KA values.put(new Float(MockConfigurationDAO.DOT_ONE), new PersistenceHelperResourceAllocation("user1", 2)); values.put(new Float(MockConfigurationDAO.DOT_ONE), new PersistenceHelperResourceAllocation("user2", 1)); values.put(new Float(MockConfigurationDAO.DOT_ONE), new PersistenceHelperResourceAllocation("user3", 1)); // No user4 // No user5 values.put(new Float(MockConfigurationDAO.DOT_ONE), new PersistenceHelperResourceAllocation("user6", 2)); values.put(new Float(MockConfigurationDAO.DOT_ONE), new PersistenceHelperResourceAllocation("user7", 3)); // T10KB values.put(new Float(MockConfigurationDAO.DOT_TWO), new PersistenceHelperResourceAllocation("user1", 3)); values.put(new Float(MockConfigurationDAO.DOT_TWO), new PersistenceHelperResourceAllocation("user2", 2)); // No user3 values.put(new Float(MockConfigurationDAO.DOT_TWO), new PersistenceHelperResourceAllocation("user4", 1)); // No user5 // No user6 values.put(new Float(MockConfigurationDAO.DOT_TWO), new PersistenceHelperResourceAllocation("user7", 3)); // T10KC // No user1 // No user2 // No user3 // No user4 values.put(new Float(MockConfigurationDAO.DOT_TWO), new PersistenceHelperResourceAllocation("user5", 1)); values.put(new Float(MockConfigurationDAO.DOT_TWO), new PersistenceHelperResourceAllocation("user6", 1)); values.put(new Float(MockConfigurationDAO.DOT_TWO), new PersistenceHelperResourceAllocation("user6", 2)); LOGGER.trace("< getResourceAllocation"); return values; }
From source file:gov.nih.nci.lmp.refExport.AnnotationExporterHelper.java
/** * Generate DataSource map.//w ww .j av a2s.co m * * @param pwElem the pw elem * @return the string */ private MultiMap generateDataSourceMap(PathwayElement pwElem) { MultiMap dataSourceMap = new MultiValueMap(); if (isNotBlank(pwElem.getDataSource().getFullName())) { dataSourceMap.put(pwElem.getGraphId(), pwElem.getTextLabel()); dataSourceMap.put(pwElem.getGraphId(), pwElem.getDataSource().getFullName()); dataSourceMap.put(pwElem.getGraphId(), pwElem.getGeneID()); } return dataSourceMap; }
From source file:gov.nih.nci.lmp.refExport.AnnotationExporterHelper.java
/** * Generate comment map./*from w w w .j a v a 2 s . c o m*/ * * @param pwElem the pw elem * @return the string */ private MultiMap generateCommentMap(PathwayElement pwElem) { MultiMap commentMap = new MultiValueMap(); // Map comments for (Comment comment : pwElem.getComments()) { commentMap.put(pwElem.getGraphId(), comment.toString()); } return commentMap; }
From source file:net.jadler.JadlerMockerTest.java
@Test public void onRequestWithDefaults() { final StubHttpServer server = mock(StubHttpServer.class); final StubbingFactory sf = spy(new StubbingFactory()); final JadlerMocker mocker = new JadlerMocker(server, sf); final MultiMap defaultHeaders = new MultiValueMap(); defaultHeaders.put(HEADER_NAME1, HEADER_VALUE1); defaultHeaders.put(HEADER_NAME2, HEADER_VALUE2); mocker.setDefaultStatus(DEFAULT_STATUS); mocker.setDefaultHeaders(defaultHeaders); mocker.setDefaultEncoding(DEFAULT_ENCODING); //ok, this is not a pure unit test, it depends on the Stubbing.respond() method as well. //the response() method is called so a HttpMockResponse is created internally. mocker.onRequest().respond();/*from ww w . j a va 2 s . c o m*/ //verify the Stubbing instance was created with the given defaults verify(sf, times(1)).createStubbing(eq(DEFAULT_ENCODING), eq(DEFAULT_STATUS), eq(defaultHeaders)); verifyNoMoreInteractions(sf); }
From source file:net.jadler.stubbing.MutableStubResponse.java
/** * Removes all occurrences of the given header in this stub response (using a case insensitive search) * and sets its single value.// w w w. j av a 2 s.co m * @param name header name * @param value header value */ @SuppressWarnings("unchecked") void setHeaderCaseInsensitive(final String name, final String value) { final MultiMap result = new MultiValueMap(); for (final Object o : this.headers.keySet()) { final String key = (String) o; //fucking non-generics MultiMap if (!name.equalsIgnoreCase(key)) { //copy all other headers to the result multimap for (final String s : (Collection<String>) this.headers.get(o)) { result.put(o, s); } } } this.headers.clear(); this.headers.putAll(result); this.addHeader(name, value); }
From source file:edu.uci.ics.jung.algorithms.blockmodel.GraphCollapser.java
/** * INTERNAL (undocumented) method//from www. j av a 2s .com * @param m * @param dest * @param superV */ protected void replaceWith(MultiMap m, Vertex dest, CollapsedVertex superV) { Collection c = (Collection) m.get(dest); for (Iterator iter = c.iterator(); iter.hasNext();) { m.put(superV, iter.next()); } m.remove(dest); }