Search in sources :

Example 21 with SimpleEntry

use of java.util.AbstractMap.SimpleEntry in project chassis by Kixeye.

the class ConfigurationBuilderTest method missingZookeeperConfig_writeDefaults.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void missingZookeeperConfig_writeDefaults() throws Exception {
    TestUtils.writePropertiesToFile(TEST_APP_CONFIG_PROPERTIES, filesCreated, new SimpleEntry(BootstrapConfigKeys.PUBLISH_DEFAULTS_KEY.getPropertyName(), "true"));
    TestUtils.deleteAll(curatorFramework);
    Assert.assertNull(curatorFramework.checkExists().forPath(ZOOKEEPER_CONFIG_ROOT));
    configurationBuilder.withConfigurationProvider(new ZookeeperConfigurationProvider(zookeeperServer.getConnectString()));
    configurationBuilder.withApplicationProperties("file://" + TEST_APP_CONFIG_PROPERTIES);
    configurationBuilder.build();
    Assert.assertNotNull(curatorFramework.checkExists().forPath(ZOOKEEPER_CONFIG_ROOT));
    Assert.assertEquals(MODULE_1_VALUE_1, new String(curatorFramework.getData().forPath(ZOOKEEPER_CONFIG_ROOT + "/" + MODULE_1_KEY_1)));
    Assert.assertEquals(MODULE_1_VALUE_2, new String(curatorFramework.getData().forPath(ZOOKEEPER_CONFIG_ROOT + "/" + MODULE_1_KEY_2)));
    Assert.assertEquals(MODULE_1_VALUE_3, new String(curatorFramework.getData().forPath(ZOOKEEPER_CONFIG_ROOT + "/" + MODULE_1_KEY_3)));
    Assert.assertEquals(MODULE_2_VALUE_1, new String(curatorFramework.getData().forPath(ZOOKEEPER_CONFIG_ROOT + "/" + MODULE_2_KEY_1)));
    Assert.assertEquals(4, curatorFramework.getChildren().forPath(ZOOKEEPER_CONFIG_ROOT).size());
}
Also used : SimpleEntry(java.util.AbstractMap.SimpleEntry) ZookeeperConfigurationProvider(com.kixeye.chassis.bootstrap.configuration.zookeeper.ZookeeperConfigurationProvider) Test(org.junit.Test)

Example 22 with SimpleEntry

use of java.util.AbstractMap.SimpleEntry in project chassis by Kixeye.

the class ConfigurationBuilderTest method fetchFromArchaius.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void fetchFromArchaius() {
    TestUtils.writePropertiesToFile(TEST_APP_CONFIG_PROPERTIES, filesCreated, new SimpleEntry(MODULE_1_KEY_2, MODULE_1_VALUE_2 + "-override"), new SimpleEntry(MODULE_1_KEY_3, MODULE_1_VALUE_3 + "-override"));
    TestUtils.writePropertiesToFile(TEST_APP_CONFIG_PROPERTIES.replace(".properties", "." + ENVIRONMENT + ".properties"), filesCreated, new SimpleEntry(MODULE_1_KEY_2, MODULE_1_VALUE_2 + "-override"));
    configurationBuilder.withApplicationProperties(TEST_APP_CONFIG_PROPERTIES_SPRING_PATH);
    Configuration configuration = configurationBuilder.build();
    Assert.assertEquals(MODULE_1_VALUE_1, configuration.getString(MODULE_1_KEY_1));
    Assert.assertEquals(MODULE_1_VALUE_2 + "-override", configuration.getString(MODULE_1_KEY_2));
    Assert.assertEquals(MODULE_1_VALUE_3 + "-override", configuration.getString(MODULE_1_KEY_3));
    Assert.assertEquals(MODULE_1_VALUE_1, DynamicPropertyFactory.getInstance().getStringProperty(MODULE_1_KEY_1, null).getValue());
    Assert.assertEquals(MODULE_1_VALUE_2 + "-override", DynamicPropertyFactory.getInstance().getStringProperty(MODULE_1_KEY_2, null).getValue());
    Assert.assertEquals(MODULE_1_VALUE_3 + "-override", DynamicPropertyFactory.getInstance().getStringProperty(MODULE_1_KEY_3, null).getValue());
}
Also used : Configuration(org.apache.commons.configuration.Configuration) SimpleEntry(java.util.AbstractMap.SimpleEntry) Test(org.junit.Test)

Example 23 with SimpleEntry

use of java.util.AbstractMap.SimpleEntry in project chassis by Kixeye.

the class ConfigurationBuilderTest method missingZookeeperConfig_writeDefaultsDisabledInConfig.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test(expected = ApplicationConfigurationNotFoundException.class)
public void missingZookeeperConfig_writeDefaultsDisabledInConfig() throws Exception {
    TestUtils.writePropertiesToFile(TEST_APP_CONFIG_PROPERTIES, filesCreated, new SimpleEntry(BootstrapConfigKeys.PUBLISH_DEFAULTS_KEY.getPropertyName(), "false"));
    TestUtils.deleteAll(curatorFramework);
    Assert.assertNull(curatorFramework.checkExists().forPath(ZOOKEEPER_CONFIG_ROOT));
    configurationBuilder.withConfigurationProvider(new ZookeeperConfigurationProvider(zookeeperServer.getConnectString()));
    configurationBuilder.withApplicationProperties("file://" + TEST_APP_CONFIG_PROPERTIES);
    configurationBuilder.build();
}
Also used : SimpleEntry(java.util.AbstractMap.SimpleEntry) ZookeeperConfigurationProvider(com.kixeye.chassis.bootstrap.configuration.zookeeper.ZookeeperConfigurationProvider) Test(org.junit.Test)

Example 24 with SimpleEntry

use of java.util.AbstractMap.SimpleEntry in project lucene-solr by apache.

the class DocumentDictionaryTest method generateIndexDocuments.

/** Returns Pair(list of invalid document terms, Map of document term -> document) */
private Map.Entry<List<String>, Map<String, Document>> generateIndexDocuments(int ndocs, boolean requiresContexts) {
    Map<String, Document> docs = new HashMap<>();
    List<String> invalidDocTerms = new ArrayList<>();
    for (int i = 0; i < ndocs; i++) {
        Document doc = new Document();
        boolean invalidDoc = false;
        Field field = null;
        // usually have valid term field in document
        if (usually()) {
            field = new TextField(FIELD_NAME, "field_" + i, Field.Store.YES);
            doc.add(field);
        } else {
            invalidDoc = true;
        }
        // even if payload is not required usually have it
        if (usually()) {
            Field payload = new StoredField(PAYLOAD_FIELD_NAME, new BytesRef("payload_" + i));
            doc.add(payload);
        }
        if (requiresContexts || usually()) {
            if (usually()) {
                for (int j = 0; j < atLeast(2); j++) {
                    doc.add(new StoredField(CONTEXT_FIELD_NAME, new BytesRef("context_" + i + "_" + j)));
                }
            }
        // we should allow entries without context
        }
        // usually have valid weight field in document
        if (usually()) {
            Field weight = (rarely()) ? new StoredField(WEIGHT_FIELD_NAME, 100d + i) : new NumericDocValuesField(WEIGHT_FIELD_NAME, 100 + i);
            doc.add(weight);
        }
        String term = null;
        if (invalidDoc) {
            term = (field != null) ? field.stringValue() : "invalid_" + i;
            invalidDocTerms.add(term);
        } else {
            term = field.stringValue();
        }
        docs.put(term, doc);
    }
    return new SimpleEntry<>(invalidDocTerms, docs);
}
Also used : HashMap(java.util.HashMap) SimpleEntry(java.util.AbstractMap.SimpleEntry) ArrayList(java.util.ArrayList) Document(org.apache.lucene.document.Document) IndexableField(org.apache.lucene.index.IndexableField) StoredField(org.apache.lucene.document.StoredField) NumericDocValuesField(org.apache.lucene.document.NumericDocValuesField) Field(org.apache.lucene.document.Field) TextField(org.apache.lucene.document.TextField) StoredField(org.apache.lucene.document.StoredField) NumericDocValuesField(org.apache.lucene.document.NumericDocValuesField) TextField(org.apache.lucene.document.TextField) BytesRef(org.apache.lucene.util.BytesRef)

Example 25 with SimpleEntry

use of java.util.AbstractMap.SimpleEntry in project ddf by codice.

the class SolrProviderTest method testUpdateNonUniqueAttributeValue2.

/**
     * Tests if we catch a rare case where some attribute value match multiple Metacards while
     * others do not match any records.
     *
     * @throws IngestException
     * @throws UnsupportedQueryException
     */
@Test(expected = IngestException.class)
public void testUpdateNonUniqueAttributeValue2() throws IngestException, UnsupportedQueryException {
    deleteAllIn(provider);
    MockMetacard m1 = new MockMetacard(Library.getFlagstaffRecord());
    MockMetacard m2 = new MockMetacard(Library.getFlagstaffRecord());
    List<Metacard> list = Arrays.asList((Metacard) m1, m2);
    create(list);
    provider.update(new UpdateRequest() {

        @Override
        public boolean hasProperties() {
            return false;
        }

        @Override
        public Serializable getPropertyValue(String name) {
            return null;
        }

        @Override
        public Set<String> getPropertyNames() {
            return null;
        }

        @Override
        public Map<String, Serializable> getProperties() {
            return null;
        }

        @Override
        public boolean containsPropertyName(String name) {
            return false;
        }

        @Override
        public List<Entry<Serializable, Metacard>> getUpdates() {
            MockMetacard newMetacard = new MockMetacard(Library.getShowLowRecord());
            List<Entry<Serializable, Metacard>> updateList = new ArrayList<Entry<Serializable, Metacard>>();
            updateList.add(new SimpleEntry<Serializable, Metacard>(MockMetacard.DEFAULT_TITLE, newMetacard));
            updateList.add(new SimpleEntry<Serializable, Metacard>(TAMPA_QUERY_PHRASE, newMetacard));
            return updateList;
        }

        @Override
        public String getAttributeName() {
            return Metacard.TITLE;
        }
    });
}
Also used : Serializable(java.io.Serializable) Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) UpdateRequest(ddf.catalog.operation.UpdateRequest) SimpleEntry(java.util.AbstractMap.SimpleEntry) Matchers.containsString(org.hamcrest.Matchers.containsString) Metacard(ddf.catalog.data.Metacard) Entry(java.util.Map.Entry) SimpleEntry(java.util.AbstractMap.SimpleEntry) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) Map(java.util.Map) Test(org.junit.Test)

Aggregations

SimpleEntry (java.util.AbstractMap.SimpleEntry)47 Test (org.junit.Test)24 ArrayList (java.util.ArrayList)21 HashMap (java.util.HashMap)15 CucumberFeature (cucumber.runtime.model.CucumberFeature)10 Result (gherkin.formatter.model.Result)10 Entry (java.util.Map.Entry)10 HashSet (java.util.HashSet)9 Map (java.util.Map)8 Metacard (ddf.catalog.data.Metacard)7 Serializable (java.io.Serializable)7 HazelcastInstance (com.hazelcast.core.HazelcastInstance)6 List (java.util.List)6 UpdateRequest (ddf.catalog.operation.UpdateRequest)5 Set (java.util.Set)5 Configuration (org.apache.commons.configuration.Configuration)5 ZookeeperConfigurationProvider (com.kixeye.chassis.bootstrap.configuration.zookeeper.ZookeeperConfigurationProvider)4 LinkedList (java.util.LinkedList)4 DetailAST (com.puppycrawl.tools.checkstyle.api.DetailAST)3 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)3