Example usage for java.util Map containsValue

List of usage examples for java.util Map containsValue

Introduction

In this page you can find the example usage for java.util Map containsValue.

Prototype

boolean containsValue(Object value);

Source Link

Document

Returns true if this map maps one or more keys to the specified value.

Usage

From source file:com.googlecode.concurrentlinkedhashmap.ConcurrentMapTest.java

@Test(dataProvider = "warmedMap")
public void containsValue_whenFound(Map<Integer, Integer> map) {
    assertThat(map.containsValue(-1), is(true));
}

From source file:com.googlecode.concurrentlinkedhashmap.ConcurrentMapTest.java

@Test(dataProvider = "warmedMap")
public void containsValue_whenNotFound(Map<Integer, Integer> map) {
    assertThat(map.containsValue(1), is(false));
}

From source file:com.eviware.soapui.impl.wsdl.support.wsdl.CachedWsdlLoader.java

private void setFilenameForUrl(String fileUrl, String type, Map<String, String> urlToFileMap)
        throws MalformedURLException {
    URL url = new URL(fileUrl);
    String path = url.getPath();/*from w w w .j a v  a2s . co  m*/

    int ix = path.lastIndexOf('/');
    String fileName = ix == -1 ? path : path.substring(ix + 1);

    ix = fileName.lastIndexOf('.');
    if (ix != -1)
        fileName = fileName.substring(0, ix);

    if (type.equals(Constants.WSDL11_NS))
        fileName += ".wsdl";
    else if (type.equals(Constants.XSD_NS))
        fileName += ".xsd";
    else
        fileName += ".xml";

    while (urlToFileMap.containsValue(fileName)) {
        ix = fileName.lastIndexOf('.');
        fileName = fileName.substring(0, ix) + "_" + fileName.substring(ix);
    }

    urlToFileMap.put(fileUrl, fileName);
}

From source file:cn.bzvs.excel.imports.ExcelImportServer.java

/**
 * ???//  w w  w  . j av  a2s.co m
 * @param titlemap
 * @param excelParams
 * @param params
 * @param excelCollection 
 */
private void checkIsValidTemplate(Map<Integer, String> titlemap, Map<String, ExcelImportEntity> excelParams,
        ImportParams params, List<ExcelCollectionParams> excelCollection) {

    if (params.getImportFields() != null) {
        for (int i = 0, le = params.getImportFields().length; i < le; i++) {
            if (!titlemap.containsValue(params.getImportFields()[i])) {
                throw new ExcelImportException(ExcelImportEnum.IS_NOT_A_VALID_TEMPLATE);
            }
        }
    } else {
        Collection<ExcelImportEntity> collection = excelParams.values();
        for (ExcelImportEntity excelImportEntity : collection) {
            if (excelImportEntity.isImportField() && !titlemap.containsValue(excelImportEntity.getName())) {
                throw new ExcelImportException(ExcelImportEnum.IS_NOT_A_VALID_TEMPLATE);
            }
        }

        for (int i = 0, le = excelCollection.size(); i < le; i++) {
            ExcelCollectionParams collectionparams = excelCollection.get(i);
            collection = collectionparams.getExcelParams().values();
            for (ExcelImportEntity excelImportEntity : collection) {
                if (excelImportEntity.isImportField() && !titlemap
                        .containsValue(collectionparams.getExcelName() + "_" + excelImportEntity.getName())) {
                    throw new ExcelImportException(ExcelImportEnum.IS_NOT_A_VALID_TEMPLATE);
                }
            }
        }
    }
}

From source file:org.craftercms.social.services.system.impl.SocialContextServiceImpl.java

@Override
@HasPermission(type = SocialPermission.class, action = SecurityActionNames.SYSTEM_ADD_PROFILE_CONTEXT)
public Profile addProfileToContext(final String profileId, final String contextId, final String[] roles)
        throws SocialException {
    try {//from  ww w .  ja v  a2  s.  c  om
        Profile p = profileService.getProfile(profileId, SocialSecurityUtils.SOCIAL_CONTEXTS_ATTRIBUTE);
        if (p == null) {
            throw new ProfileConfigurationException("Given profile \"" + profileId + "\" does not exist");
        }
        final HashMap<String, Object> attributesToUpdate = new HashMap<>();
        List<Map<String, Object>> socialContexts = p
                .getAttribute(SocialSecurityUtils.SOCIAL_CONTEXTS_ATTRIBUTE);
        SocialContext ctx = socialContextRepository.findById(contextId);
        if (ctx == null) {
            throw new ProfileConfigurationException("Given context \"" + contextId + "\" does not exist");
        }
        if (CollectionUtils.isEmpty(socialContexts)) {
            Map<String, Object> socialContext = new HashMap<>();
            socialContext.put(SocialSecurityUtils.SOCIAL_CONTEXT_NAME, ctx.getContextName());
            socialContext.put(SocialSecurityUtils.SOCIAL_CONTEXT_ID, ctx.getId());
            socialContext.put(SocialSecurityUtils.SOCIAL_CONTEXT_ROLES, Arrays.asList(roles));
            socialContexts = Arrays.asList(socialContext);
        } else {
            boolean foundOne = false;
            for (Map<String, Object> socialContext : socialContexts) {
                if (socialContext.containsValue(ctx.getId())) {
                    socialContext.put(SocialSecurityUtils.SOCIAL_CONTEXT_ROLES, Arrays.asList(roles));
                    foundOne = true;
                    break;
                }
            }
            if (!foundOne) {
                Map<String, Object> newCtx = new HashMap<>();
                newCtx.put(SocialSecurityUtils.SOCIAL_CONTEXT_NAME, ctx.getContextName());
                newCtx.put(SocialSecurityUtils.SOCIAL_CONTEXT_ID, ctx.getId());
                newCtx.put(SocialSecurityUtils.SOCIAL_CONTEXT_ROLES, Arrays.asList(roles));
                socialContexts.add(newCtx);
            }
        }
        attributesToUpdate.put(SocialSecurityUtils.SOCIAL_CONTEXTS_ATTRIBUTE, socialContexts);
        return profileService.updateAttributes(profileId, attributesToUpdate, FIRST_NAME_ATTRIBUTE,
                LAST_NAME_ATTRIBUTE, DISPLAY_NAME_ATTRIBUTE, AVATAR_LINK_ATTRIBUTE,
                SocialSecurityUtils.SOCIAL_CONTEXTS_ATTRIBUTE);
    } catch (ProfileException e) {
        log.error("Unable to find profile with given id " + profileId, e);
        throw new SocialException("Unable to find profile ", e);
    } catch (MongoDataException e) {
        log.error("Unable to look for SocialContext", e);
        throw new SocialException("Unable to find Context by id", e);
    }
}

From source file:org.mule.test.routing.ForeachTestCase.java

@Test
public void mvelMap() throws Exception {
    MuleMessage parent = new DefaultMuleMessage(null, muleContext);
    client.send("vm://input-19", parent);

    Map<String, String> m = new HashMap<String, String>();
    m.put("key1", "val1");
    m.put("key2", "val2");

    MuleMessage out = client.request("vm://out", getTestTimeoutSecs());
    assertTrue(out.getPayload() instanceof String);
    String outPayload = (String) out.getPayload();
    assertTrue(m.containsValue(outPayload));

    out = client.request("vm://out", getTestTimeoutSecs());
    assertTrue(out.getPayload() instanceof String);
    outPayload = (String) out.getPayload();
    assertTrue(m.containsValue(outPayload));
}

From source file:org.mule.test.routing.ForeachTestCase.java

@Test
public void mvelCollection() throws Exception {
    MuleMessage parent = new DefaultMuleMessage(null, muleContext);
    client.send("vm://input-20", parent);

    Map<String, String> m = new HashMap<String, String>();
    m.put("key1", "val1");
    m.put("key2", "val2");

    MuleMessage out = client.request("vm://out", getTestTimeoutSecs());
    assertTrue(out.getPayload() instanceof String);
    String outPayload = (String) out.getPayload();
    assertTrue(m.containsValue(outPayload));

    out = client.request("vm://out", getTestTimeoutSecs());
    assertTrue(out.getPayload() instanceof String);
    outPayload = (String) out.getPayload();
    assertTrue(m.containsValue(outPayload));
}

From source file:org.kuali.rice.krad.service.impl.RemoteModuleServiceBase.java

/**
 * @see org.kuali.rice.krad.service.ModuleService#getExternalizableBusinessObjectImplementation(java.lang.Class)
 *//*w  w w . ja va 2 s  . c o  m*/
@Override
public <E extends ExternalizableBusinessObject> Class<E> getExternalizableBusinessObjectImplementation(
        Class<E> externalizableBusinessObjectInterface) {
    if (getModuleConfiguration() == null) {
        throw new IllegalStateException(
                "Module configuration has not been initialized for the module service.");
    }
    Map<Class, Class> ebos = getModuleConfiguration().getExternalizableBusinessObjectImplementations();
    if (ebos == null) {
        return null;
    }
    if (ebos.containsValue(externalizableBusinessObjectInterface)) {
        return externalizableBusinessObjectInterface;
    } else {
        Class<E> implementationClass = ebos.get(externalizableBusinessObjectInterface);

        int implClassModifiers = implementationClass.getModifiers();
        if (Modifier.isInterface(implClassModifiers) || Modifier.isAbstract(implClassModifiers)) {
            throw new RuntimeException("Implementation class must be non-abstract class: ebo interface: "
                    + externalizableBusinessObjectInterface.getName() + " impl class: "
                    + implementationClass.getName() + " module: "
                    + getModuleConfiguration().getNamespaceCode());
        }
        return implementationClass;
    }

}

From source file:com.palantir.atlasdb.keyvalue.impl.AbstractAtlasDbKeyValueServiceTest.java

@Test
public void testGetWhenMultipleVersions() {
    putTestDataForMultipleTimestamps();//from www.  j a v a2s. c o  m
    Cell cell = Cell.create(row0, column0);
    Value val0 = Value.create(value0_t0, TEST_TIMESTAMP);
    Value val1 = Value.create(value0_t1, TEST_TIMESTAMP + 1);

    assertTrue(keyValueService.get(TEST_TABLE, ImmutableMap.of(cell, TEST_TIMESTAMP)).isEmpty());

    Map<Cell, Value> result = keyValueService.get(TEST_TABLE, ImmutableMap.of(cell, TEST_TIMESTAMP + 1));
    assertTrue(result.containsKey(cell));
    assertEquals(1, result.size());
    assertTrue(result.containsValue(val0));

    result = keyValueService.get(TEST_TABLE, ImmutableMap.of(cell, TEST_TIMESTAMP + 2));

    assertEquals(1, result.size());
    assertTrue(result.containsKey(cell));
    assertTrue(result.containsValue(val1));

    result = keyValueService.get(TEST_TABLE, ImmutableMap.of(cell, TEST_TIMESTAMP + 3));

    assertEquals(1, result.size());
    assertTrue(result.containsKey(cell));
    assertTrue(result.containsValue(val1));
}

From source file:com.linkedin.pinot.controller.api.resources.PinotSegmentUploadRestletResource.java

private JSONArray getSegments(String tableName, String tableType) {

    final JSONArray ret = new JSONArray();

    String realtimeTableName = TableNameBuilder.REALTIME.tableNameWithType(tableName);
    String offlineTableName = TableNameBuilder.OFFLINE.tableNameWithType(tableName);

    String tableNameWithType;//from  w  ww.  j av  a2s .  co  m
    if (CommonConstants.Helix.TableType.valueOf(tableType).toString().equals("REALTIME")) {
        tableNameWithType = realtimeTableName;
    } else {
        tableNameWithType = offlineTableName;
    }

    List<String> segmentList = _pinotHelixResourceManager.getSegmentsFor(tableNameWithType);
    IdealState idealState = HelixHelper.getTableIdealState(_pinotHelixResourceManager.getHelixZkManager(),
            tableNameWithType);

    for (String segmentName : segmentList) {
        Map<String, String> map = idealState.getInstanceStateMap(segmentName);
        if (map == null) {
            continue;
        }
        if (!map.containsValue(PinotHelixSegmentOnlineOfflineStateModelGenerator.OFFLINE_STATE)) {
            ret.put(segmentName);
        }
    }

    return ret;
}