Example usage for java.util Collections EMPTY_MAP

List of usage examples for java.util Collections EMPTY_MAP

Introduction

In this page you can find the example usage for java.util Collections EMPTY_MAP.

Prototype

Map EMPTY_MAP

To view the source code for java.util Collections EMPTY_MAP.

Click Source Link

Document

The empty map (immutable).

Usage

From source file:org.asqatasun.sebuilder.interpreter.TgTestRun.java

/**
 * /*from   w ww.j  a v  a  2  s .  c o m*/
 * @param url 
 */
private void getSourceCodeAndFireNewPage(String url) {
    try {
        try {
            Thread.sleep(500);
        } catch (InterruptedException ex) {
            throw new TestRunException(currentStep() + " failed.", ex, currentStep().toString(), stepIndex);
        }
        String sourceCode = getDriver().getPageSource();

        /* ##############################################################
         * ACHTUNG !!!!!!!!!!!!!!!!!!!!!!!!!!
         * this sendKeys action is here to grab the focus on the page.
         * It is needed later by the js script to execute the focus()
         * method on each element. Without it, the focus is kept by the adress
         * bar.
         */
        WebElement body = getDriver().findElementByTagName("html");
        Map<String, String> jsScriptResult = Collections.EMPTY_MAP;
        try {
            body.sendKeys(Keys.TAB);
            jsScriptResult = executeJsScripts();
        } catch (WebDriverException wde) {
            getLog().warn(wde.getMessage());
        }
        /*##############################################################*/

        /* byte[] snapshot = createPageSnapshot();*/
        for (NewPageListener npl : newPageListeners) {
            npl.fireNewPage(url, sourceCode, null, jsScriptResult);
        }
    } catch (UnhandledAlertException uae) {
        getLog().warn(uae.getMessage());
        throw new TestRunException(currentStep() + " failed.", uae, currentStep().toString(), stepIndex);
    }
}

From source file:com.facebook.litho.DebugComponent.java

/**
 * @return Key-value mapping of this components layout styles.
 *//*from  www  . j  av  a  2s . com*/
public Map<String, Object> getStyles() {
    final InternalNode node = mNode.get();
    if (node == null || !isLayoutNode()) {
        return Collections.EMPTY_MAP;
    }

    final Map<String, Object> styles = new ArrayMap<>();
    final YogaNode yogaNode = node.mYogaNode;
    final YogaNode defaults = ComponentsPools.acquireYogaNode(node.getContext());
    final ComponentContext context = node.getContext();

    styles.put("background", getReferenceColor(context, node.getBackground()));
    styles.put("foreground", getDrawableColor(node.getForeground()));

    styles.put("direction", yogaNode.getStyleDirection());
    styles.put("flex-direction", yogaNode.getFlexDirection());
    styles.put("justify-content", yogaNode.getJustifyContent());
    styles.put("align-items", yogaNode.getAlignItems());
    styles.put("align-self", yogaNode.getAlignSelf());
    styles.put("align-content", yogaNode.getAlignContent());
    styles.put("position", yogaNode.getPositionType());
    styles.put("flex-grow", yogaNode.getFlexGrow());
    styles.put("flex-shrink", yogaNode.getFlexShrink());
    styles.put("flex-basis", yogaNode.getFlexBasis());

    styles.put("width", yogaNode.getWidth());
    styles.put("min-width", yogaNode.getMinWidth());
    styles.put("max-width", yogaNode.getMaxWidth());
    styles.put("height", yogaNode.getHeight());
    styles.put("min-height", yogaNode.getMinHeight());
    styles.put("max-height", yogaNode.getMaxHeight());

    for (YogaEdge edge : edges) {
        final String key = "margin-" + edge.toString().toLowerCase();
        styles.put(key, yogaNode.getMargin(edge));
    }

    for (YogaEdge edge : edges) {
        final String key = "padding-" + edge.toString().toLowerCase();
        styles.put(key, yogaNode.getPadding(edge));
    }

    for (YogaEdge edge : edges) {
        final String key = "position-" + edge.toString().toLowerCase();
        styles.put(key, yogaNode.getPosition(edge));
    }

    for (YogaEdge edge : edges) {
        final String key = "border-" + edge.toString().toLowerCase();
        final float border = yogaNode.getBorder(edge);
        styles.put(key, Float.isNaN(border) ? 0 : border);
    }

    ComponentsPools.release(defaults);
    return styles;
}

From source file:com.redhat.rhn.domain.kickstart.KickstartFactory.java

/**
 * Returns a list of kickstart data cobbler ids
 * this is useful for cobbler only profiles..
 * @return a list of cobbler ids./*from ww  w .ja  v a  2  s  . c  o  m*/
 */
public static List<String> listKickstartDataCobblerIds() {
    return singleton.listObjectsByNamedQuery("KickstartData.cobblerIds", Collections.EMPTY_MAP);

}

From source file:com.oneops.inductor.InductorTest.java

@Test
public void testWoExecutorConfigWithNoCloudServiceEnvVar() {
    CmsWorkOrderSimple wo = gson.fromJson(remoteWo, CmsWorkOrderSimple.class);
    wo.setServices(Collections.EMPTY_MAP);
    Config cfg = new Config();
    cfg.setCircuitDir("/opt/oneops/inductor/packer");
    cfg.setIpAttribute("public_ip");
    cfg.setEnv("");
    cfg.init();/*from ww  w .j  av  a2  s  . co m*/
    WorkOrderExecutor executor = new WorkOrderExecutor(cfg, mock(Semaphore.class));
    final String vars = executor.getProxyEnvVars(wo);
    assertTrue(vars.equals(
            "rubygems_proxy=http://repos.org/gemrepo/ rubygemsbkp_proxy=http://dal-repos.org/gemrepo/ ruby_proxy= DATACENTER_proxy=dal misc_proxy=http://repos.org/mirrored-assets/apache.mirrors.pair.com/ class=user pack=circuit-oneops-1"));
}

From source file:fr.inria.atlanmod.neoemf.map.datastore.MapPersistenceBackendFactoryTest.java

@Test
public void testCreatePersistentEStoreAutocommitOption() throws InvalidDataStoreException, NoSuchFieldException,
        SecurityException, IllegalArgumentException, IllegalAccessException {
    storeOptions.add(MapResourceOptions.EStoreMapOption.AUTOCOMMIT);
    PersistenceBackend persistentBackend = persistenceBackendFactory.createPersistentBackend(testFile,
            Collections.EMPTY_MAP);
    SearcheableResourceEStore eStore = persistenceBackendFactory.createPersistentEStore(null, persistentBackend,
            options);//from   w  w  w. ja v a  2 s .  c o  m
    assert eStore instanceof AutocommitMapResourceEStoreImpl : "Invaild EStore created";
    PersistenceBackend innerBackend = getInnerBackend((DirectWriteMapResourceEStoreImpl) eStore);
    assert innerBackend == persistentBackend : "The backend in the EStore is not the created one";
}

From source file:org.apache.tiles.definition.TestUrlDefinitionsFactory.java

/**
 * Tests the addDefinitions method under normal
 * circumstances./*w w w .  ja  v  a  2 s.c  om*/
 *
 * @throws Exception If something goes wrong.
 */
@SuppressWarnings("unchecked")
public void testReadByLocale() throws Exception {
    MockPublicUrlDefinitionsFactory factory = new MockPublicUrlDefinitionsFactory();

    // Set up multiple data sources.
    URL url1 = this.getClass().getClassLoader().getResource("org/apache/tiles/config/defs1.xml");
    assertNotNull("Could not load defs1 file.", url1);
    URL url2 = this.getClass().getClassLoader().getResource("org/apache/tiles/config/defs2.xml");
    assertNotNull("Could not load defs2 file.", url2);
    URL url3 = this.getClass().getClassLoader().getResource("org/apache/tiles/config/defs3.xml");
    assertNotNull("Could not load defs3 file.", url3);

    factory.init(Collections.EMPTY_MAP);
    factory.addSource(url1);
    factory.addSource(url2);
    factory.addSource(url3);

    // Parse files.
    Definitions definitions = factory.readDefinitions();
    factory.addDefinitions(definitions, new MockOnlyLocaleTilesContext(Locale.US));
    factory.addDefinitions(definitions, new MockOnlyLocaleTilesContext(Locale.FRENCH));

    assertNotNull("test.def1 definition not found.", definitions.getDefinition("test.def1"));
    assertNotNull("test.def1 US definition not found.", definitions.getDefinition("test.def1", Locale.US));
    assertNotNull("test.def1 France definition not found.",
            definitions.getDefinition("test.def1", Locale.FRENCH));
    assertNotNull("test.def1 China should return default.",
            definitions.getDefinition("test.def1", Locale.CHINA));

    assertEquals("Incorrect default country value", "default",
            definitions.getDefinition("test.def1").getAttribute("country").getValue());
    assertEquals("Incorrect US country value", "US",
            definitions.getDefinition("test.def1", Locale.US).getAttribute("country").getValue());
    assertEquals("Incorrect France country value", "France",
            definitions.getDefinition("test.def1", Locale.FRENCH).getAttribute("country").getValue());
    assertEquals("Incorrect Chinese country value (should default)", "default",
            definitions.getDefinition("test.def1", Locale.CHINA).getAttribute("country").getValue());
}

From source file:com.jaspersoft.jasperserver.war.cascade.token.FilterCore.java

/**
 * Resolve the build-in parameters if any are used in the query.
 * If we still have missing params then return null
 * @return map of actual params resolved
 *///  ww w.ja  va 2 s. co  m
public Map<String, Object> resolveParameters(String queryString, Map<String, Object> providedParameters) {

    Set<String> queryParameterNames = getParameterNames(queryString, providedParameters);
    // Map is empty, thus we guarantee that no class cast error will occur
    @SuppressWarnings("unchecked")
    Map<String, Object> allParams = new LinkedHashMap<String, Object>(
            providedParameters != null ? providedParameters : Collections.EMPTY_MAP);

    // The Build-In parameters values have higher priority than provided ones if there are any.
    // Rewriting resolved values...
    Map<String, Object> resolvedBuildInParams = resolveBuiltInParameters(queryParameterNames);
    allParams.putAll(resolvedBuildInParams);

    Map<String, Object> resolvedParams = new LinkedHashMap<String, Object>();
    Set<String> missingQueryParameterNames = new LinkedHashSet<String>();
    for (String parameterName : queryParameterNames) {
        if (allParams.containsKey(parameterName)) {
            resolvedParams.put(parameterName, allParams.get(parameterName));
        } else {
            missingQueryParameterNames.add(parameterName);
        }
    }

    if (log.isDebugEnabled()) {
        log.debug("provided params: " + providedParameters);
        log.debug("resolved params: " + resolvedParams);
        log.debug("resolved build-in params: " + resolvedBuildInParams);
        log.debug("missing params: " + missingQueryParameterNames);
    }

    // If we still have missing params then return null
    if (missingQueryParameterNames.size() > 0) {
        resolvedParams = null;
    }

    if (log.isDebugEnabled() && missingQueryParameterNames.size() > 0) {
        log.debug("final resolved params: " + resolvedParams);
    }
    return resolvedParams;
}

From source file:com.impetus.ankush2.framework.monitor.AbstractMonitor.java

/**
 * Gets the logs.//from  ww w  . ja v  a 2s .  co m
 * 
 * @return the logs
 */
public Map getLogs() {
    int lastLog = 0;
    if (parameterMap.containsKey(com.impetus.ankush2.constant.Constant.Keys.LASTLOG)) {
        lastLog = ParserUtil
                .getIntValue((String) parameterMap.get(com.impetus.ankush2.constant.Constant.Keys.LASTLOG), 0);
    }
    String host = null;
    if (parameterMap.containsKey(com.impetus.ankush2.constant.Constant.Keys.HOST)) {
        host = (String) parameterMap.get(com.impetus.ankush2.constant.Constant.Keys.HOST);
    }
    // Getting last operation id.
    Long operationId = getOperationId();
    if (operationId == null) {
        addAndLogError("Could not get logs.");
        return Collections.EMPTY_MAP;
    }
    // Creating Empty property/value map.
    Map<String, Object> propertyValueMap = new HashMap<String, Object>();

    // putting cluster id.
    propertyValueMap.put(com.impetus.ankush2.constant.Constant.Keys.CLUSTERID, dbCluster.getId());

    // putting host public ip
    if (host != null && !host.isEmpty()) {
        propertyValueMap.put(com.impetus.ankush2.constant.Constant.Keys.HOST, host);

    }

    // putting last operation id.
    propertyValueMap.put(com.impetus.ankush2.constant.Constant.Keys.OPERATIONID, operationId);
    List<Log> logs = logManager.getAllByPropertyValue(propertyValueMap,
            com.impetus.ankush2.constant.Constant.Keys.ID);

    logs.subList(0, lastLog).clear();

    lastLog = lastLog + logs.size();

    Map map = new HashMap();
    map.put(com.impetus.ankush2.constant.Constant.Keys.LOGS, logs);
    map.put(com.impetus.ankush2.constant.Constant.Keys.LASTLOG, lastLog);
    map.put(com.impetus.ankush2.constant.Constant.Keys.STATE, dbCluster.getState());
    map.put(com.impetus.ankush2.constant.Constant.Keys.OPERATION_STATE,
            new DBOperationManager().getOperationStatus(dbCluster.getId(), operationId));
    return map;
}

From source file:org.apache.accumulo.test.AuditMessageTest.java

@Test(timeout = 60 * 1000)
@SuppressWarnings("unchecked")
public void testTableOperationsAudits() throws AccumuloException, AccumuloSecurityException,
        TableExistsException, TableNotFoundException, IOException, InterruptedException {

    conn.securityOperations().createLocalUser(AUDIT_USER_1, new PasswordToken(PASSWORD));
    conn.securityOperations().grantSystemPermission(AUDIT_USER_1, SystemPermission.SYSTEM);
    conn.securityOperations().grantSystemPermission(AUDIT_USER_1, SystemPermission.CREATE_TABLE);

    // Connect as Audit User and do a bunch of stuff.
    // Testing activity begins here
    auditConnector = accumulo.getConnector(AUDIT_USER_1, PASSWORD);
    auditConnector.tableOperations().create(OLD_TEST_TABLE_NAME);
    auditConnector.tableOperations().rename(OLD_TEST_TABLE_NAME, NEW_TEST_TABLE_NAME);
    auditConnector.tableOperations().clone(NEW_TEST_TABLE_NAME, OLD_TEST_TABLE_NAME, true,
            Collections.EMPTY_MAP, Collections.EMPTY_SET);
    auditConnector.tableOperations().delete(OLD_TEST_TABLE_NAME);
    auditConnector.tableOperations().offline(NEW_TEST_TABLE_NAME);
    auditConnector.tableOperations().delete(NEW_TEST_TABLE_NAME);
    // Testing activity ends here

    ArrayList<String> auditMessages = getAuditMessages("testTableOperationsAudits");

    assertEquals(1,/* ww w.j av  a 2s. co m*/
            findAuditMessage(auditMessages, "action: createTable; targetTable: " + OLD_TEST_TABLE_NAME).size());
    assertEquals(1,
            findAuditMessage(auditMessages, "action: renameTable; targetTable: " + OLD_TEST_TABLE_NAME).size());
    assertEquals(1,
            findAuditMessage(auditMessages, "action: cloneTable; targetTable: " + NEW_TEST_TABLE_NAME).size());
    assertEquals(1,
            findAuditMessage(auditMessages, "action: deleteTable; targetTable: " + OLD_TEST_TABLE_NAME).size());
    assertEquals(1, findAuditMessage(auditMessages, "action: offlineTable; targetTable: " + NEW_TEST_TABLE_NAME)
            .size());
    assertEquals(1,
            findAuditMessage(auditMessages, "action: deleteTable; targetTable: " + NEW_TEST_TABLE_NAME).size());

}

From source file:org.apache.cayenne.wocompat.EOModelHelper.java

public Map getPrototypeAttributeMapFor(String aPrototypeAttributeName) {
    if (prototypeValues == null) {

        Map eoPrototypesEntityMap = this.entityPListMap("EOPrototypes");

        // no prototypes
        if (eoPrototypesEntityMap == null) {
            prototypeValues = Collections.EMPTY_MAP;
        } else {/*from  w w  w. java  2 s.c o m*/
            List eoPrototypeAttributes = (List) eoPrototypesEntityMap.get("attributes");

            prototypeValues = new HashMap();
            Iterator it = eoPrototypeAttributes.iterator();
            while (it.hasNext()) {
                Map attrMap = (Map) it.next();

                String attrName = (String) attrMap.get("name");

                // TODO: why are we copying the original map? can we just use it as is?
                Map prototypeAttrMap = new HashMap();
                prototypeValues.put(attrName, prototypeAttrMap);

                prototypeAttrMap.put("name", attrMap.get("name"));
                prototypeAttrMap.put("prototypeName", attrMap.get("prototypeName"));
                prototypeAttrMap.put("columnName", attrMap.get("columnName"));
                prototypeAttrMap.put("valueClassName", attrMap.get("valueClassName"));
                prototypeAttrMap.put("width", attrMap.get("width"));
                prototypeAttrMap.put("allowsNull", attrMap.get("allowsNull"));
                prototypeAttrMap.put("scale", attrMap.get("scale"));
                prototypeAttrMap.put("valueType", attrMap.get("valueType"));
                prototypeAttrMap.put("externalType", attrMap.get("externalType"));
            }
        }
    }

    Map aMap = (Map) prototypeValues.get(aPrototypeAttributeName);
    if (null == aMap)
        aMap = Collections.EMPTY_MAP;

    return aMap;
}