org.eclipse.collections.impl.factory.Maps Java Examples

The following examples show how to use org.eclipse.collections.impl.factory.Maps. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CsvReaderDataSourceTest.java    From obevo with Apache License 2.0 6 votes vote down vote up
private void verifyCsv(String input, MutableList<String> keyFields, MutableMap<String, String>... rows) throws Exception {
    CsvReaderDataSource ds = new CsvReaderDataSource(csvVersion, "test", new StringReader(input), ',', StringFunctions.toLowerCase(), "null");
    ds.setCatoConfiguration(new CatoSimpleJavaConfiguration(new SimpleCatoProperties(keyFields)));
    ds.init();
    ds.open();
    final MutableList<Map<String, Object>> dataRows = IteratorIterate.collect(ds, new Function<CatoDataObject, Map<String, Object>>() {
        @Override
        public Map<String, Object> valueOf(CatoDataObject catoDataObject) {
            Map<String, Object> data = Maps.mutable.empty();
            for (String field : catoDataObject.getFields()) {
                data.put(field, catoDataObject.getValue(field));
            }
            data.remove(CsvReaderDataSource.ROW_NUMBER_FIELD);

            return data;
        }
    }, Lists.mutable.<Map<String, Object>>empty());
    ds.close();

    assertEquals(rows.length, dataRows.size());
    for (int i = 0; i < dataRows.size(); i++) {
        assertEquals("Error on row " + i, rows[i], dataRows.get(i));
    }
}
 
Example #2
Source File: PackageMetadataReaderTest.java    From obevo with Apache License 2.0 6 votes vote down vote up
@Test
public void testPackageMetadataWithMetadataAndProperties() {
    PackageMetadataReader packageMetadataReader = new PackageMetadataReader(new TextMarkupDocumentReader(false));

    PackageMetadata packageMetadata = packageMetadataReader.getPackageMetadata("\n\n  \n  \n" +
            "//// METADATA k1=v1 k2=v2 toggle1 toggle2\n" +
            "sourceEncodings.UTF-8=a1,a2,a3\n" +
            "sourceEncodings.UTF-16=a4\n" +
            "otherProps=abc\n" +
            "\n");

    assertEquals(Maps.immutable.of("k1", "v1", "k2", "v2"), packageMetadata.getMetadataSection().getAttrs());
    assertEquals(Sets.immutable.of("toggle1", "toggle2"), packageMetadata.getMetadataSection().getToggles());

    assertEquals(Maps.mutable.of(
            "a1", "UTF-8",
            "a2", "UTF-8",
            "a3", "UTF-8",
            "a4", "UTF-16"
            )
            , packageMetadata.getFileToEncodingMap());
}
 
Example #3
Source File: ChangeRestrictionsReaderTest.java    From obevo with Apache License 2.0 6 votes vote down vote up
@Test
public void testIncludeEnvsExcludePlatforms() {
    ImmutableList<ArtifactRestrictions> restrictions = this.restrictionsReader.valueOf(
            this.doc(TextMarkupDocumentReader.TAG_METADATA, null,
                    Maps.immutable.with(
                            "includeEnvs", "dev1,dev3",
                            "excludePlatforms", "HSQL,HIVE"))
    );
    assertEquals(2, restrictions.size());

    assertThat(restrictions.getFirst(), instanceOf(ArtifactEnvironmentRestrictions.class));
    assertEquals(UnifiedSet.newSetWith("dev1", "dev3"), restrictions.getFirst().getIncludes());
    assertTrue(restrictions.getFirst().getExcludes().isEmpty());

    assertThat(restrictions.getLast(), instanceOf(ArtifactPlatformRestrictions.class));
    assertTrue(restrictions.getLast().getIncludes().isEmpty());
    assertEquals(UnifiedSet.newSetWith("HSQL", "HIVE"), restrictions.getLast().getExcludes());
}
 
Example #4
Source File: TextMarkupDocumentReaderTest.java    From obevo with Apache License 2.0 6 votes vote down vote up
@Test
public void testQuotedSplitWithEqualSignAndSpace() {
    String input = "attr=1234 attr2=\"56 = 78\" mytog1";
    if (legacyMode) {
        try {
            textMarkupDocumentReader.parseAttrsAndToggles(input);
            fail("Should have failed here");
        } catch (ArrayIndexOutOfBoundsException e) {
            assertThat(e.getMessage(), notNullValue());
        }
    } else {
        Pair<ImmutableMap<String, String>, ImmutableSet<String>> results = textMarkupDocumentReader.parseAttrsAndToggles(input);

        assertEquals(Maps.mutable.of("attr", "1234", "attr2", "56 = 78"), results.getOne());
        assertEquals(Sets.mutable.of("mytog1"), results.getTwo());
    }
}
 
Example #5
Source File: SummaryTest.java    From warnings-ng-plugin with MIT License 6 votes vote down vote up
/**
 * Tests the creation of the html when multiple conditions are met.
 */
@Test
void shouldProvideSummary() {
    AnalysisResult analysisResult = createAnalysisResult(
            Maps.fixedSize.of("checkstyle", 15, "pmd", 20), 2, 2,
            EMPTY_ERRORS, 1);
    Summary summary = createSummary(analysisResult);

    String actualSummary = summary.create();
    assertThat(actualSummary).contains("CheckStyle, PMD");
    assertThat(actualSummary).contains("No warnings for 2 builds");
    assertThat(actualSummary).contains("since build <a href=\"../1\" class=\"model-link inside\">1</a>");
    assertThat(actualSummary).containsPattern(
            createWarningsLink("<a href=\"test/new\">.*2 new warnings.*</a>"));
    assertThat(actualSummary).containsPattern(
            createWarningsLink("<a href=\"test/fixed\">.*2 fixed warnings.*</a>"));
    assertThat(actualSummary).contains(
            "Quality gate: <img src=\"color\" class=\"icon-blue\" alt=\"Success\" title=\"Success\"> Success\n");
    assertThat(actualSummary).contains("Reference build: <a href=\"absoluteUrl\">Job #15</a>");
}
 
Example #6
Source File: TextMarkupDocumentReaderTest.java    From obevo with Apache License 2.0 6 votes vote down vote up
@Test
public void testWordEndingInEqualSignWillFailInLegacy() {
    String input = "   attr= abc";
    if (legacyMode) {
        try {
            textMarkupDocumentReader.parseAttrsAndToggles(input);
            fail("Should have failed here");
        } catch (ArrayIndexOutOfBoundsException expected) {
        }
    } else {
        Pair<ImmutableMap<String, String>, ImmutableSet<String>> results = textMarkupDocumentReader.parseAttrsAndToggles(input);

        assertEquals(Maps.mutable.of("attr", ""), results.getOne());
        assertEquals(Sets.mutable.of("abc"), results.getTwo());
    }
}
 
Example #7
Source File: Exercise3Test.java    From reladomo-kata with Apache License 2.0 6 votes vote down vote up
/**
 * Sum the ages of all {@code Pet}s.
 * Use Reladomo's aggregation methods.
 * <p>
 * <p>Name {@code groupBy} column as "personId</p>
 * <p>Name {@code sum} column as "petAge"</p>
 * <p>Use appropriate methods on {@link AggregateList}</p>
 */
@Test
public void getTotalAgeOfAllSmithPets()
{
    AggregateList aggregateList = null;

    aggregateList.addAggregateAttribute("petAge", PetFinder.petAge().sum());
    aggregateList.addGroupBy("personId", PetFinder.personId());

    MutableMap<Integer, Integer> personIdToTotalPetAgeMap = Iterate.toMap(
            aggregateList,
            aggregateData -> aggregateData.getAttributeAsInteger("personId"),
            aggregateData -> aggregateData.getAttributeAsInteger("petAge")
    );

    Verify.assertMapsEqual(
            Maps.mutable.with(1, 3, 2, 20, 3, 4),
            personIdToTotalPetAgeMap
    );
}
 
Example #8
Source File: TextMarkupDocumentReaderTest.java    From obevo with Apache License 2.0 6 votes vote down vote up
@Test
public void testQuotedSplitWithEqualSign() {
    String input = "attr=1234 attr2=\"56=78\" mytog1";
    if (legacyMode) {
        try {
            textMarkupDocumentReader.parseAttrsAndToggles(input);
            fail("Should have failed here");
        } catch (IllegalArgumentException e) {
            assertThat(e.getMessage(), containsString("Cannot mark = multiple times"));
        }
    } else {
        Pair<ImmutableMap<String, String>, ImmutableSet<String>> results = textMarkupDocumentReader.parseAttrsAndToggles(input);

        assertEquals(Maps.mutable.of("attr", "1234", "attr2", "56=78"), results.getOne());
        assertEquals(Sets.mutable.of("mytog1"), results.getTwo());
    }
}
 
Example #9
Source File: PackageMetadataReaderTest.java    From obevo with Apache License 2.0 6 votes vote down vote up
@Test
public void testPackageMetadataWithProperties() {
    PackageMetadataReader packageMetadataReader = new PackageMetadataReader(new TextMarkupDocumentReader(false));

    PackageMetadata packageMetadata = packageMetadataReader.getPackageMetadata("\n\n  \n  \n" +
            "sourceEncodings.UTF-8=a1,a2,a3\n" +
            "sourceEncodings.UTF-16=a4\n" +
            "otherProps=abc\n" +
            "\n");

    assertNull(packageMetadata.getMetadataSection());

    assertEquals(Maps.immutable.of(
            "a1", "UTF-8",
            "a2", "UTF-8",
            "a3", "UTF-8",
            "a4", "UTF-16"
            )
            , packageMetadata.getFileToEncodingMap());
}
 
Example #10
Source File: OptionDialog.java    From mylizzie with GNU General Public License v3.0 6 votes vote down vote up
private void initOtherComponents() {
    getRootPane().registerKeyboardAction(e -> setVisible(false),
            KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            JComponent.WHEN_IN_FOCUSED_WINDOW);

    getRootPane().registerKeyboardAction(e -> doApplySettings(),
            KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),
            JComponent.WHEN_IN_FOCUSED_WINDOW);

    MutableMap<OptionSetting.BoardSize, JRadioButton> m = Maps.mutable.empty();
    m.put(new OptionSetting.BoardSize(19, 19), radioButtonBoard19x19);
    m.put(new OptionSetting.BoardSize(15, 15), radioButtonBoard15x15);
    m.put(new OptionSetting.BoardSize(13, 13), radioButtonBoard13x13);
    m.put(new OptionSetting.BoardSize(9, 9), radioButtonBoard9x9);
    m.put(new OptionSetting.BoardSize(7, 7), radioButtonBoard7x7);
    m.put(new OptionSetting.BoardSize(5, 5), radioButtonBoard5x5);

    boardSizeToRadioButtonMap = m.toImmutable();
}
 
Example #11
Source File: PrepareDbChangeForDb.java    From obevo with Apache License 2.0 6 votes vote down vote up
@Override
public String prepare(String content, ChangeInput change, DbEnvironment env) {
    MutableMap<String, String> tokens = Maps.mutable.<String, String>empty()
            .withKeyValue("dbSchemaSuffix", env.getDbSchemaSuffix())
            .withKeyValue("dbSchemaPrefix", env.getDbSchemaPrefix());

    for (Schema schema : env.getSchemas()) {
        PhysicalSchema physicalSchema = env.getPhysicalSchema(schema.getName());
        tokens.put(schema.getName() + "_physicalName", physicalSchema.getPhysicalName());
        if (env.getPlatform() != null) {
            tokens.put(schema.getName() + "_schemaSuffixed", env.getPlatform().getSchemaPrefix(physicalSchema));
            tokens.put(schema.getName() + "_subschemaSuffixed", env.getPlatform().getSubschemaPrefix(physicalSchema));
        }
    }

    if (env.getDefaultTablespace() != null) {
        tokens.put("defaultTablespace", env.getDefaultTablespace());
    }

    tokens.putAll(env.getTokens().castToMap());  // allow clients to override these values if needed

    return new Tokenizer(tokens, env.getTokenPrefix(), env.getTokenSuffix()).tokenizeString(content);
}
 
Example #12
Source File: AquaRevengMain.java    From obevo with Apache License 2.0 6 votes vote down vote up
private ImmutableMap<ChangeType, Pattern> initPatternMap(Platform platform) {
    MutableMap<String, Pattern> params = Maps.mutable.<String, Pattern>with()
            .withKeyValue(ChangeType.SP_STR, Pattern.compile("(?i)create\\s+proc(?:edure)?\\s+(\\w+)", Pattern.DOTALL))
            .withKeyValue(ChangeType.FUNCTION_STR, Pattern.compile("(?i)create\\s+func(?:tion)?\\s+(\\w+)", Pattern.DOTALL))
            .withKeyValue(ChangeType.VIEW_STR, Pattern.compile("(?i)create\\s+view\\s+(\\w+)", Pattern.DOTALL))
            .withKeyValue(ChangeType.SEQUENCE_STR, Pattern.compile("(?i)create\\s+seq(?:uence)?\\s+(\\w+)", Pattern.DOTALL))
            .withKeyValue(ChangeType.TABLE_STR, Pattern.compile("(?i)create\\s+table\\s+(\\w+)", Pattern.DOTALL))
            .withKeyValue(ChangeType.DEFAULT_STR, Pattern.compile("(?i)create\\s+default\\s+(\\w+)", Pattern.DOTALL))
            .withKeyValue(ChangeType.RULE_STR, Pattern.compile("(?i)create\\s+rule\\s+(\\w+)", Pattern.DOTALL))
            .withKeyValue(ChangeType.USERTYPE_STR, Pattern.compile("(?i)^\\s*sp_addtype\\s+", Pattern.DOTALL))
            .withKeyValue(ChangeType.INDEX_STR, Pattern.compile("(?i)create\\s+(?:unique\\s+)?(?:\\w+\\s+)?index\\s+\\w+\\s+on\\s+(\\w+)", Pattern.DOTALL));

    MutableMap<ChangeType, Pattern> patternMap = Maps.mutable.<ChangeType, Pattern>with();
    for (String changeTypeName : params.keysView()) {
        if (platform.hasChangeType(changeTypeName)) {
            ChangeType changeType = platform.getChangeType(changeTypeName);
            patternMap.put(changeType, params.get(changeTypeName));
        }
    }

    return patternMap.toImmutable();
}
 
Example #13
Source File: ApiExampleForDocumentation.java    From obevo with Apache License 2.0 6 votes vote down vote up
public void programmaticEnvCreation() {
    DbEnvironment dbEnv = new DbEnvironment();
    dbEnv.setSourceDirs(Lists.immutable.with(FileRetrievalMode.FILE_SYSTEM.resolveSingleFileObject("./src/test/resources/platforms/h2/step1")));
    dbEnv.setName("test");
    dbEnv.setPlatform(new H2DbPlatform());
    dbEnv.setSchemas(Sets.immutable.with(new Schema("SCHEMA1"), new Schema("SCHEMA2")));
    dbEnv.setDbServer("BLAH");

    dbEnv.setSchemaNameOverrides(Maps.immutable.of("SCHEMA1", "bogusSchema"));
    dbEnv.setNullToken("(null)");
    dbEnv.setDataDelimiter('^');

    DeployerAppContext context = Obevo.buildContext(dbEnv, new Credential("sa", ""));

    context.setupEnvInfra();
    context.cleanEnvironment();
    context.deploy();
}
 
Example #14
Source File: PlatformConfiguration.java    From obevo with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the default name-to-platform mappings. We put this in a separate protected method to allow external
 * distributions to override these values as needed.
 */
private ImmutableMap<String, ImmutableHierarchicalConfiguration> getDbPlatformMap() {
    final String platformKey = "db.platforms";

    ListIterable<ImmutableHierarchicalConfiguration> platformConfigs = ListAdapter.adapt(config.immutableChildConfigurationsAt("db.platforms"));

    MutableMap<String, ImmutableHierarchicalConfiguration> platformByName = Maps.mutable.empty();

    for (ImmutableHierarchicalConfiguration platformConfig : platformConfigs) {
        String platformName = platformConfig.getRootElementName();
        String platformClass = platformConfig.getString("class");
        if (platformClass == null) {
            LOG.warn("Improper platform config under {} for platform {}: missing class property. Will skip", platformKey, platformName);
        } else {
            platformByName.put(platformName, platformConfig);
            LOG.debug("Registering platform {} at class {}", platformName, platformClass);
        }
    }

    return platformByName.toImmutable();
}
 
Example #15
Source File: SchemaGenerator.java    From obevo with Apache License 2.0 6 votes vote down vote up
private void generate(String schema) {
    MutableSet<MyInput> inputs = Sets.mutable.empty();

    inputs.withAll(getUserTypes(numTypes));
    inputs.withAll(getTables());
    inputs.withAll(getViews());
    inputs.withAll(getSps());

    MutableSet<String> types = Sets.mutable.of("table", "view", "sp", "usertype");
    File outputDir = new File("./target/testoutput");
    FileUtils.deleteQuietly(outputDir);
    outputDir.mkdirs();
    for (MyInput input : inputs) {
        MutableMap<String, Object> params = Maps.mutable.<String, Object>empty().withKeyValue(
                "name", input.getName()
        );
        for (String type : types) {
            params.put("dependent" + type + "s", input.getDependenciesByType().get(type));
        }

        File outputFile = new File(outputDir, schema + "/" + input.getType() + "/" + input.getName() + ".sql");
        outputFile.getParentFile().mkdirs();
        TestTemplateUtil.getInstance().writeTemplate("schemagen/" + input.getType() + ".sql.ftl", params, outputFile);
    }
}
 
Example #16
Source File: IqDataSource.java    From obevo with Apache License 2.0 6 votes vote down vote up
public IqDataSource(DbEnvironment env, Credential userCredential, int numThreads, IqDataSourceFactory subDataSourceFactory) {
    this.env = env;
    this.subDataSourceFactory = subDataSourceFactory;

    MutableMap<PhysicalSchema, DataSource> dsMap = Maps.mutable.empty();
    for (PhysicalSchema physicalSchema : env.getPhysicalSchemas()) {
        String schema = physicalSchema.getPhysicalName();
        LOG.info("Creating datasource against schema {}", schema);
        DataSource ds = subDataSourceFactory.createDataSource(env,
                userCredential,
                schema,
                numThreads
        );

        dsMap.put(physicalSchema, ds);
    }

    this.dsMap = dsMap.toImmutable();
    this.setCurrentSchema(this.env.getPhysicalSchemas().getFirst());  // set one arbitrarily as the default
}
 
Example #17
Source File: TextMarkupDocumentReaderTest.java    From obevo with Apache License 2.0 5 votes vote down vote up
@Test
public void testSlashWithQuoteNoEscaping() {
    Pair<ImmutableMap<String, String>, ImmutableSet<String>> results = textMarkupDocumentReader.parseAttrsAndToggles(
            " 123  attr=\"abc\\\"d ef\"  \\  456=789"
    );

    if (legacyMode) {
        assertEquals(Maps.mutable.of("attr", "\"abc\\\"d", "456", "789"), results.getOne());
        assertEquals(Sets.mutable.of("123", "\\", "ef\""), results.getTwo());
    } else {
        assertEquals(Maps.mutable.of("attr", "abc\"d ef", "456", "789"), results.getOne());
        assertEquals(Sets.mutable.of("123", "\\"), results.getTwo());
    }
}
 
Example #18
Source File: TextMarkupDocumentReaderTest.java    From obevo with Apache License 2.0 5 votes vote down vote up
@Test
public void testSlashWithQuoteNoEscaping2() {
    Pair<ImmutableMap<String, String>, ImmutableSet<String>> results = textMarkupDocumentReader.parseAttrsAndToggles(
            " 123  attr=\"abc\\d ef\"  \\  456=789"
    );

    if (legacyMode) {
        assertEquals(Maps.mutable.of("attr", "\"abc\\d", "456", "789"), results.getOne());
        assertEquals(Sets.mutable.of("123", "\\", "ef\""), results.getTwo());
    } else {
        assertEquals(Maps.mutable.of("attr", "abc\\d ef", "456", "789"), results.getOne());
        assertEquals(Sets.mutable.of("123", "\\"), results.getTwo());
    }
}
 
Example #19
Source File: TextMarkupDocumentReaderTest.java    From obevo with Apache License 2.0 5 votes vote down vote up
@Test
public void testSimpleLineParsing() {
    Pair<ImmutableMap<String, String>, ImmutableSet<String>> results = textMarkupDocumentReader.parseAttrsAndToggles(
            "attr=1234 attr2=\"5678\" mytog1"
    );

    assertEquals(Maps.mutable.of("attr", "1234", "attr2", "5678"), results.getOne());
    assertEquals(Sets.mutable.of("mytog1"), results.getTwo());
}
 
Example #20
Source File: TextMarkupDocumentReaderTest.java    From obevo with Apache License 2.0 5 votes vote down vote up
@Test
public void testPackageMetadataWithMetaInOriginal() {
    TextMarkupDocumentSection packageMetaSection = new TextMarkupDocumentSection(TextMarkupDocumentReader.TAG_METADATA, null, Maps.immutable.of("k1", "v1", "k2ToOverride", "v2Original"));
    TextMarkupDocument doc = textMarkupDocumentReader.parseString(
            "//// " + TextMarkupDocumentReader.TAG_METADATA + " k2ToOverride=v2Overriden k3=newv3\r\n" +
                    "content"
            , packageMetaSection
    );

    assertSection(doc.getSections().get(0), TextMarkupDocumentReader.TAG_METADATA, null, Maps.immutable.of("k1", "v1", "k2ToOverride", "v2Overriden", "k3", "newv3"));
}
 
Example #21
Source File: TextMarkupDocumentReaderTest.java    From obevo with Apache License 2.0 5 votes vote down vote up
@Test
public void testBehaviorOfStringStartingWithEqualSign() {
    Pair<ImmutableMap<String, String>, ImmutableSet<String>> results = textMarkupDocumentReader.parseAttrsAndToggles(
            " e  q =attr  1234 attr2=\"5678\"\" \"\"mytog1\"  "
    );

    if (legacyMode) {
        assertEquals(Maps.mutable.of("", "attr", "attr2", "5678\""), results.getOne());
        assertEquals(Sets.mutable.of("1234", "\"\"mytog1\"", "e", "q"), results.getTwo());
    } else {
        assertEquals(Maps.mutable.of("attr2", "5678\""), results.getOne());
        assertEquals(Sets.mutable.of("=", "attr", "1234", "\"\"mytog1\"", "e", "q"), results.getTwo());
    }
}
 
Example #22
Source File: TextMarkupDocumentReaderTest.java    From obevo with Apache License 2.0 5 votes vote down vote up
@Test
public void testEqualSignInQuoteValueWillFailInLegacy() {
    String input = "   attr=\"abc=123\" ";
    if (legacyMode) {
        try {
            textMarkupDocumentReader.parseAttrsAndToggles(input);
            fail("Should throw exception here");
        } catch (IllegalArgumentException expected) {
        }
    } else {
        Pair<ImmutableMap<String, String>, ImmutableSet<String>> results = textMarkupDocumentReader.parseAttrsAndToggles(input);
        assertEquals(Maps.mutable.of("attr", "abc=123"), results.getOne());
        assertEquals(Sets.mutable.empty(), results.getTwo());
    }
}
 
Example #23
Source File: ChangeRestrictionsReaderTest.java    From obevo with Apache License 2.0 5 votes vote down vote up
@Test
public void testWrongNoEnvsSpecified() {
    assertTrue(this.restrictionsReader.valueOf(
            this.doc(TextMarkupDocumentReader.TAG_METADATA, null,
                    Maps.immutable.with("wrongIncludePrefix", "dev1,dev3"))
    ).isEmpty());
}
 
Example #24
Source File: TextMarkupDocumentReaderTest.java    From obevo with Apache License 2.0 5 votes vote down vote up
@Test
public void testEqualSignAloneWillFailInLegacy() {
    String input = " a = b ";
    if (legacyMode) {
        try {
            textMarkupDocumentReader.parseAttrsAndToggles(input);
            fail("Should throw exception here");
        } catch (ArrayIndexOutOfBoundsException expected) {
        }
    } else {
        Pair<ImmutableMap<String, String>, ImmutableSet<String>> results = textMarkupDocumentReader.parseAttrsAndToggles(input);
        assertEquals(Maps.mutable.empty(), results.getOne());
        assertEquals(Sets.mutable.of("a", "b", "="), results.getTwo());
    }
}
 
Example #25
Source File: ChangeRestrictionsReaderTest.java    From obevo with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testWrongBothIncludeExcludeEnvsSpecified() {
    this.restrictionsReader.valueOf(
            this.doc(TextMarkupDocumentReader.TAG_METADATA, null,
                    Maps.immutable.with("includeEnvs", "dev1,dev3", "excludeEnvs", "dev1,dev3"))
    );
}
 
Example #26
Source File: ChangeRestrictionsReaderTest.java    From obevo with Apache License 2.0 5 votes vote down vote up
@Test
public void testIncludePlatforms() {
    ImmutableList<ArtifactRestrictions> restrictions = this.restrictionsReader.valueOf(
            this.doc(TextMarkupDocumentReader.TAG_METADATA, null,
                    Maps.immutable.with("includePlatforms", "DB2,SYBASE_ASE"))
    );
    assertEquals(1, restrictions.size());
    assertThat(restrictions.getFirst(), instanceOf(ArtifactPlatformRestrictions.class));
    assertEquals(UnifiedSet.newSetWith("DB2", "SYBASE_ASE"), restrictions.getFirst().getIncludes());
    assertTrue(restrictions.getFirst().getExcludes().isEmpty());
}
 
Example #27
Source File: TextMarkupDocumentReaderTest.java    From obevo with Apache License 2.0 5 votes vote down vote up
@Test
public void testQuoteWithinQuotedStringIsPreservedIfNoSpace() {
    Pair<ImmutableMap<String, String>, ImmutableSet<String>> results = textMarkupDocumentReader.parseAttrsAndToggles(
            "   abc=attr  1234 attr2=\"56\"78\" mytog1  "
    );

    assertEquals(Maps.mutable.of("abc", "attr", "attr2", "56\"78"), results.getOne());
    assertEquals(Sets.mutable.of("1234", "mytog1"), results.getTwo());
}
 
Example #28
Source File: TextMarkupDocumentReaderTest.java    From obevo with Apache License 2.0 5 votes vote down vote up
@Test
public void testQuoteWithinStringIsStillPreservedEvenIfStringIsntClosedForBackwardsCompatibility() {
    Pair<ImmutableMap<String, String>, ImmutableSet<String>> results = textMarkupDocumentReader.parseAttrsAndToggles(
            "   =attr  1234 attr2=\"56\"78 mytog1  "
    );

    if (legacyMode) {
        assertEquals(Maps.mutable.of("", "attr", "attr2", "\"56\"78"), results.getOne());
        assertEquals(Sets.mutable.of("1234", "mytog1"), results.getTwo());
    } else {
        assertEquals(Maps.mutable.of("attr2", "\"56\"78"), results.getOne());
        assertEquals(Sets.mutable.of("=", "attr", "1234", "mytog1"), results.getTwo());
    }
}
 
Example #29
Source File: ChangeRestrictionsReaderTest.java    From obevo with Apache License 2.0 5 votes vote down vote up
@Test
public void testExcludePlatforms() {
    ImmutableList<ArtifactRestrictions> restrictions = this.restrictionsReader.valueOf(
            this.doc(TextMarkupDocumentReader.TAG_METADATA, null,
                    Maps.immutable.with("excludePlatforms", "HSQL,HIVE"))
    );
    assertEquals(1, restrictions.size());
    assertEquals(UnifiedSet.newSetWith("HSQL", "HIVE"), restrictions.getFirst().getExcludes());
    assertTrue(restrictions.getFirst().getIncludes().isEmpty());
}
 
Example #30
Source File: ChangeRestrictionsReaderTest.java    From obevo with Apache License 2.0 5 votes vote down vote up
@Test
public void testExcludeEnvs() {
    ImmutableList<ArtifactRestrictions> restrictions = this.restrictionsReader.valueOf(
            this.doc(TextMarkupDocumentReader.TAG_METADATA, null,
                    Maps.immutable.with("excludeEnvs", "dev1,dev3"))
    );
    assertEquals(1, restrictions.size());
    assertThat(restrictions.getFirst(), instanceOf(ArtifactEnvironmentRestrictions.class));
    assertEquals(UnifiedSet.newSetWith("dev1", "dev3"), restrictions.getFirst().getExcludes());
    assertTrue(restrictions.getFirst().getIncludes().isEmpty());
}