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.apache.atlas.web.integration.EntityJerseyResourceIT.java

@Test
public void testRequestUser() throws Exception {
    Referenceable entity = new Referenceable(DATABASE_TYPE_BUILTIN);
    String dbName = randomString();
    entity.set("name", dbName);
    entity.set(QUALIFIED_NAME, dbName);/*  w w w .  ja v  a 2  s .  c om*/
    entity.set("clusterName", randomString());
    entity.set("description", randomString());
    entity.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, dbName);
    entity.set("owner", "user1");
    entity.set("clusterName", "cl1");
    entity.set("parameters", Collections.EMPTY_MAP);
    entity.set("location", "/tmp");

    String user = "admin";
    AtlasClient localClient = null;
    if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) {
        localClient = new AtlasClient(atlasUrls, new String[] { "admin", "admin" });
    } else {
        localClient = new AtlasClient(atlasUrls);
    }
    String entityId = localClient.createEntity(entity).get(0);

    List<EntityAuditEvent> events = atlasClientV1.getEntityAuditEvents(entityId, (short) 10);
    assertEquals(events.size(), 1);
    assertEquals(events.get(0).getUser(), user);
}

From source file:org.artificer.repository.jcr.JCRRelationshipQueryTest.java

@Test
public void testGenericRelationshipAttributeQueries() throws Exception {
    XsdDocument xsdDoc = addXsdDoc();//from  ww w .  jav a2  s.  c om
    WsdlDocument wsdlDoc1 = addWsdlDoc();
    WsdlDocument wsdlDoc2 = addWsdlDoc();
    WsdlDocument wsdlDoc3 = addWsdlDoc();

    Map<QName, String> otherAttributes = new HashMap<QName, String>();
    otherAttributes.put(QName.valueOf("FooKey"), "FooValue");
    ArtificerModelUtils.addGenericRelationship(xsdDoc, "relWithAttr", wsdlDoc1.getUuid(), otherAttributes,
            Collections.EMPTY_MAP);
    ArtificerModelUtils.addGenericRelationship(xsdDoc, "relWithAttr", wsdlDoc2.getUuid(), otherAttributes,
            Collections.EMPTY_MAP);
    Map<QName, String> otherAttributes2 = new HashMap<QName, String>();
    otherAttributes2.put(QName.valueOf("FooKey2"), "FooValue2");
    ArtificerModelUtils.addGenericRelationship(xsdDoc, "relWithAttr2", wsdlDoc3.getUuid(), otherAttributes2,
            Collections.EMPTY_MAP);

    xsdDoc = (XsdDocument) persistenceManager.updateArtifact(xsdDoc, ArtifactType.XsdDocument());

    // add custom properties only to one of the wsdls
    Property prop = new Property();
    prop.setPropertyName("FooProperty");
    prop.setPropertyValue("FooValue");
    wsdlDoc1.getProperty().add(prop);

    wsdlDoc1 = (WsdlDocument) persistenceManager.updateArtifact(wsdlDoc1, ArtifactType.WsdlDocument());

    ArtificerQuery query = queryManager
            .createQuery("/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey')]]");
    ArtifactSet artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey') = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'InvalidKey')]]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(0, artifactSet.size());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey') = 'FooValue' and @FooProperty = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey') = 'FooValue' and @InvalidProperty]]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(0, artifactSet.size());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey') = 'FooValue' or @FooProperty = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey') = 'InvalidValue' or @FooProperty = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey') = 'InvalidValue' or @FooProperty = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());

    query = queryManager.createQuery("/s-ramp/xsd/XsdDocument[@uuid = ?]/relWithAttr2");
    query.setString(xsdDoc.getUuid());
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[@uuid = ?]/relWithAttr2[s-ramp:getRelationshipAttribute(., 'FooKey2')]");
    query.setString(xsdDoc.getUuid());
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());
    Assert.assertEquals(wsdlDoc3.getUuid(), artifactSet.iterator().next().getUuid());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[@uuid = ?]/relWithAttr2[s-ramp:getRelationshipAttribute(., 'FooKey2') = 'FooValue2']");
    query.setString(xsdDoc.getUuid());
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());
    Assert.assertEquals(wsdlDoc3.getUuid(), artifactSet.iterator().next().getUuid());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[@uuid = ?]/relWithAttr2[s-ramp:getRelationshipAttribute(., 'InvalidKey')]");
    query.setString(xsdDoc.getUuid());
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(0, artifactSet.size());
}

From source file:de.hybris.platform.catalog.jalo.synchronization.ItemCopyCreatorTest.java

@Test
public void testExceptionDuringCreationOtherAttributes() throws JaloBusinessException {

    final Set<Language> languages = jaloSession.getC2LManager().getAllLanguages();
    //determine other attribute
    final CatalogVersionSyncCopyContext ctx = new CatalogVersionSyncCopyContext(syncJob, syncCronJob, worker) {
        @Override/*from  www. ja v  a2s . co m*/
        SynchronizationPersistenceAdapter getPersistenceAdapter() {
            return new LegacySynchronizationPersistenceAdapter(this) {
                @Override
                public void update(final Item entity, final Map.Entry<String, Object> attribute)
                        throws SynchronizationPersistenceException {
                    //if other attribute
                    if ("articleStatus".equalsIgnoreCase(attribute.getKey())) {
                        throw new IllegalStateException(
                                "expected exception during setting other attributes  ...");
                    }
                    super.update(entity, attribute);
                }
            };
        }

        @Override
        protected Set<Language> getTargetLanguages() {
            return languages;
        }

    };

    final Product source = ProductManager.getInstance().createProduct(PRODUCT_FAILING_ON_UPDATE);

    final EnumerationValue articleStatus = EnumerationManager.getInstance().getEnumerationValue(
            ArticleStatus._TYPECODE, GeneratedCatalogConstants.Enumerations.ArticleStatus.OTHERS);
    CatalogManager.getInstance().setArticleStatus(source, ImmutableMap.of(articleStatus, "foo"));

    final Product target = null;

    final Collection<String> whiteList = Arrays.asList(Product.CODE, ArticleStatus._TYPECODE/*
                                                                                             * , Product.NAME,
                                                                                             * Product.TYPE,
                                                                                             * Product.PK
                                                                                             */);
    final Collection<String> blackList = Arrays.asList(Product.MODIFIED_TIME, Product.CREATION_TIME);

    final Map<String, Object> presets = Collections.EMPTY_MAP;
    final ItemCopyCreator copyCreator = new ItemCopyCreator(ctx, null, source, target, blackList, whiteList,
            presets);

    final Product result = copyCreator.copy();

    Assert.assertNotNull("Result should be not null ", result);//TODO when tx feature activated any reference fail should prevent from creating the item
    Assert.assertTrue("The article status shouldn't be set ",
            MapUtils.isEmpty(CatalogManager.getInstance().getArticleStatus(result)));
}

From source file:de.betterform.xml.xforms.model.constraints.Validator.java

/**
 * Validates the specified instance data nodes.
 *
 * @param instance the instance to be validated.
 * @throws XPathException // ww w  .  j  av  a2s  . c o m
 */
public void validate(Instance instance) throws XFormsException {
    // during init validate model items in default mode: no items are
    // ignored and nothing discontinues validation. once the model is ready,
    // model items are validated in optzimized mode which simply skips
    // all unmodified model items.
    validate(instance, instance.getInstanceNodeset(), 1, "/", Collections.EMPTY_MAP, null,
            this.model.isReady() ? this.mode : new DefaultValidatorMode());
}

From source file:com.mitre.fulfilmentprocess.test.PaymentIntegrationTest.java

@Before
public void setUpProductCatalogue() {
    try {/* ww  w  .  j a  v  a  2  s . c  o m*/
        new CoreBasicDataCreator().createEssentialData(Collections.EMPTY_MAP, null);
        importCsv("/mitrefulfilmentprocess/test/testBasics.csv", "windows-1252");
        importCsv("/mitrefulfilmentprocess/test/testCatalog.csv", "windows-1252");
        baseSiteService.setCurrentBaseSite(baseSiteService.getBaseSiteForUID("testSite"), false);
        LOG.warn("Catalogue has been imported");
    } catch (final ImpExException e) {
        LOG.warn("Catalogue import has failed");
        LOG.error("Exception : ", e);
    } catch (final Exception e) {
        LOG.warn("createEssentialData(...) has failed");
        LOG.error("Exception : ", e);
    }
}

From source file:org.apache.cayenne.access.DataDomain.java

/**
 * Reinitializes domain state with a new set of properties.
 * /*from   w  ww  .  j  av  a  2s.c  o m*/
 * @since 1.1
 */
public void initWithProperties(Map<String, String> properties) {

    // clone properties to ensure that it is read-only internally
    properties = properties != null ? new HashMap<String, String>(properties) : Collections.EMPTY_MAP;

    String sharedCacheEnabled = properties.get(SHARED_CACHE_ENABLED_PROPERTY);
    String validatingObjectsOnCommit = properties.get(VALIDATING_OBJECTS_ON_COMMIT_PROPERTY);
    String usingExternalTransactions = properties.get(USING_EXTERNAL_TRANSACTIONS_PROPERTY);

    // init ivars from properties
    this.sharedCacheEnabled = (sharedCacheEnabled != null) ? "true".equalsIgnoreCase(sharedCacheEnabled)
            : SHARED_CACHE_ENABLED_DEFAULT;
    this.validatingObjectsOnCommit = (validatingObjectsOnCommit != null)
            ? "true".equalsIgnoreCase(validatingObjectsOnCommit)
            : VALIDATING_OBJECTS_ON_COMMIT_DEFAULT;
    this.usingExternalTransactions = (usingExternalTransactions != null)
            ? "true".equalsIgnoreCase(usingExternalTransactions)
            : USING_EXTERNAL_TRANSACTIONS_DEFAULT;

    this.properties = properties;
}

From source file:org.artificer.repository.test.RelationshipQueryTest.java

@Test
public void testGenericRelationshipAttributeQueries() throws Exception {
    XsdDocument xsdDoc = addXsdDoc();//from w  ww  . jav a2 s  .  c om
    WsdlDocument wsdlDoc1 = addWsdlDoc();
    WsdlDocument wsdlDoc2 = addWsdlDoc();
    WsdlDocument wsdlDoc3 = addWsdlDoc();

    Map<QName, String> otherAttributes = new HashMap<QName, String>();
    otherAttributes.put(QName.valueOf("FooKey"), "FooValue");
    ArtificerModelUtils.addGenericRelationship(xsdDoc, "relWithAttr", wsdlDoc1.getUuid(), otherAttributes,
            Collections.EMPTY_MAP);
    ArtificerModelUtils.addGenericRelationship(xsdDoc, "relWithAttr", wsdlDoc2.getUuid(), otherAttributes,
            Collections.EMPTY_MAP);
    Map<QName, String> otherAttributes2 = new HashMap<QName, String>();
    otherAttributes2.put(QName.valueOf("FooKey2"), "FooValue2");
    ArtificerModelUtils.addGenericRelationship(xsdDoc, "relWithAttr2", wsdlDoc3.getUuid(), otherAttributes2,
            Collections.EMPTY_MAP);

    xsdDoc = (XsdDocument) persistenceManager.updateArtifact(xsdDoc, ArtifactType.XsdDocument());

    // add custom properties only to one of the wsdls
    Property prop = new Property();
    prop.setPropertyName("FooProperty");
    prop.setPropertyValue("FooValue");
    wsdlDoc1.getProperty().add(prop);

    wsdlDoc1 = (WsdlDocument) persistenceManager.updateArtifact(wsdlDoc1, ArtifactType.WsdlDocument());

    ArtificerQuery query = queryManager
            .createQuery("/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey')]]");
    PagedResult<ArtifactSummary> artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey') = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'InvalidKey')]]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(0, artifactSet.getTotalSize());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey') = 'FooValue' and @FooProperty = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey') = 'FooValue' and @InvalidProperty]]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(0, artifactSet.getTotalSize());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey') = 'FooValue' or @FooProperty = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey') = 'InvalidValue' or @FooProperty = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey') = 'InvalidValue' or @FooProperty = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());

    query = queryManager.createQuery("/s-ramp/xsd/XsdDocument[@uuid = ?]/relWithAttr2");
    query.setString(xsdDoc.getUuid());
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());
    Assert.assertEquals(wsdlDoc3.getUuid(), artifactSet.getResults().get(0).getUuid());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[@uuid = ?]/relWithAttr2[s-ramp:getRelationshipAttribute(., 'FooKey2')]");
    query.setString(xsdDoc.getUuid());
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());
    Assert.assertEquals(wsdlDoc3.getUuid(), artifactSet.getResults().get(0).getUuid());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[@uuid = ?]/relWithAttr2[s-ramp:getRelationshipAttribute(., 'FooKey2') = 'FooValue2']");
    query.setString(xsdDoc.getUuid());
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());
    Assert.assertEquals(wsdlDoc3.getUuid(), artifactSet.getResults().get(0).getUuid());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[@uuid = ?]/relWithAttr2[s-ramp:getRelationshipAttribute(., 'InvalidKey')]");
    query.setString(xsdDoc.getUuid());
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(0, artifactSet.getTotalSize());
}

From source file:net.scriptability.core.ScriptAbility.java

/**
 * Starts the framework using the supplied map as the script API. API objects will be bound as script variables using the map
 * key for the variable name./*from ww w .  j a v a 2  s.c o m*/
 *
 * @param factory factory used for creating various framework services.
 */
public synchronized void start(final ScriptAbilityFactory factory) {
    start(Collections.EMPTY_MAP, new ScriptAbilityFactory());
}

From source file:org.beangle.model.persist.hibernate.CriterionUtils.java

/**
 * ??.<br>//from  w  w w .  j a  v  a  2  s.  c o m
 * component???<br>
 * componentmap??component.attr?.
 * 
 * @param entity
 *            ,null,map.
 * @param mode
 *            ??like
 * @return
 */
public static Map<String, Object> getParamsMap(Entity<?> entity, MatchMode mode) {
    if (null == entity) {
        return Collections.EMPTY_MAP;
    }
    Map<String, Object> datas = CollectUtils.newHashMap();
    String attr = "";
    try {
        Map<String, Object> beanMap = PropertyUtils.describe(entity);
        for (Iterator<String> iter = beanMap.keySet().iterator(); iter.hasNext();) {
            attr = iter.next();
            Object value = PropertyUtils.getProperty(entity, attr);
            if (value == null) {
                continue;
            } else {
                addTrivialAttr(datas, attr, value, mode);
                if (value instanceof Entity) {
                    String key = "id";
                    value = PropertyUtils.getProperty(entity, attr + "." + key);
                    if (ValidEntityKeyPredicate.getInstance().evaluate(value)) {
                        datas.put(attr + "." + key, value);
                    }
                }
            }
        }
        return datas;
    } catch (Exception e) {
        logger.error("[converToMap]:error occur in converToMap of bean" + entity + "with attr named " + attr,
                e);
    }
    return Collections.emptyMap();
}

From source file:org.codehaus.groovy.grails.commons.GrailsDomainConfigurationUtil.java

/**
 * Returns the association map for the specified domain class
 *
 * @param domainClass the domain class/*from  w w w. ja  v  a2  s  . c o m*/
 * @return The association map
 */
public static Map<?, ?> getAssociationMap(Class<?> domainClass) {
    ClassPropertyFetcher cpf = ClassPropertyFetcher.forClass(domainClass);

    Map<?, ?> associationMap = cpf.getPropertyValue(GrailsDomainClassProperty.HAS_MANY, Map.class);
    if (associationMap == null) {
        associationMap = Collections.EMPTY_MAP;
    }
    return associationMap;
}