Search in sources :

Example 26 with Joiner

use of com.google.common.base.Joiner in project jslint4java by happygiraffe.

the class MainTest method assertLintOutput.

/** Check that the exit value, stdout and stderr are as expected. */
private void assertLintOutput(int actualExit, int expectedExit, List<String> expectedStdout, List<String> expectedStderr) {
    Joiner nl = Joiner.on(NEWLINE);
    assertThat(stdio.getStdout(), is(nl.join(maybeAddTrailer(expectedStdout))));
    assertThat(stdio.getStderr(), is(nl.join(maybeAddTrailer(expectedStderr))));
    // Do this last so that we see stdout/stderr errors first.
    assertThat(actualExit, is(expectedExit));
}
Also used : Joiner(com.google.common.base.Joiner)

Example 27 with Joiner

use of com.google.common.base.Joiner in project killbill by killbill.

the class ContiguousIntervalUsageInArrear method computeToBeBilledCapacityInArrear.

/**
     * @param roUnits the list of rolled up units for the period
     * @return the price amount that should be billed for that period/unitType
     * @throws CatalogApiException
     */
@VisibleForTesting
BigDecimal computeToBeBilledCapacityInArrear(final List<RolledUpUnit> roUnits) throws CatalogApiException {
    Preconditions.checkState(isBuilt.get());
    final List<Tier> tiers = getCapacityInArrearTier(usage);
    for (final Tier cur : tiers) {
        boolean complies = true;
        for (final RolledUpUnit ro : roUnits) {
            final Limit tierLimit = getTierLimit(cur, ro.getUnitType());
            // Specifying a -1 value for last max tier will make the validation works
            if (tierLimit.getMax() != (double) -1 && ro.getAmount().doubleValue() > tierLimit.getMax()) {
                complies = false;
                break;
            }
        }
        if (complies) {
            return cur.getRecurringPrice().getPrice(getCurrency());
        }
    }
    // Probably invalid catalog config
    final Joiner joiner = Joiner.on(", ");
    joiner.join(roUnits);
    Preconditions.checkState(false, "Could not find tier for usage " + usage.getName() + "matching with data = " + joiner.join(roUnits));
    return null;
}
Also used : Joiner(com.google.common.base.Joiner) RolledUpUnit(org.killbill.billing.usage.api.RolledUpUnit) Tier(org.killbill.billing.catalog.api.Tier) UsageUtils.getCapacityInArrearTier(org.killbill.billing.invoice.usage.UsageUtils.getCapacityInArrearTier) Limit(org.killbill.billing.catalog.api.Limit) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 28 with Joiner

use of com.google.common.base.Joiner in project Cloud9 by lintool.

the class IntegrationUtils method exec.

// How to properly shell out: http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
public static PairOfStrings exec(String cmd) throws IOException, InterruptedException {
    System.out.println("Executing command: " + cmd);
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec(cmd);
    // any error message?
    StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream(), "STDERR");
    // any output?
    StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream(), "STDOUT");
    // kick them off
    errorGobbler.start();
    outputGobbler.start();
    // any error???
    int exitVal = proc.waitFor();
    System.out.println("ExitValue: " + exitVal);
    Joiner joiner = Joiner.on("\n");
    return Pair.of(joiner.join(outputGobbler.getLines()), joiner.join(errorGobbler.getLines()));
}
Also used : Joiner(com.google.common.base.Joiner)

Example 29 with Joiner

use of com.google.common.base.Joiner in project graylog2-server by Graylog2.

the class JsonExtractor method parseValue.

private Collection<Entry> parseValue(String key, Object value) {
    final String processedKey = parseKey(key);
    if (value instanceof Boolean) {
        return Collections.singleton(Entry.create(processedKey, value));
    } else if (value instanceof Number) {
        return Collections.singleton(Entry.create(processedKey, value));
    } else if (value instanceof String) {
        return Collections.singleton(Entry.create(processedKey, value));
    } else if (value instanceof Map) {
        @SuppressWarnings("unchecked") final Map<String, Object> map = (Map<String, Object>) value;
        final Map<String, Object> withoutNull = Maps.filterEntries(map, REMOVE_NULL_PREDICATE);
        if (flatten) {
            final Joiner.MapJoiner joiner = Joiner.on(listSeparator).withKeyValueSeparator(kvSeparator);
            return Collections.singleton(Entry.create(processedKey, joiner.join(withoutNull)));
        } else {
            final List<Entry> result = new ArrayList<>(map.size());
            for (Map.Entry<String, Object> entry : map.entrySet()) {
                result.addAll(parseValue(processedKey + keySeparator + entry.getKey(), entry.getValue()));
            }
            return result;
        }
    } else if (value instanceof List) {
        final List values = (List) value;
        final Joiner joiner = Joiner.on(listSeparator).skipNulls();
        return Collections.singleton(Entry.create(processedKey, joiner.join(values)));
    } else if (value == null) {
        // Ignore null values so we don't try to create fields for that in the message.
        return Collections.emptySet();
    } else {
        LOG.debug("Unknown type \"{}\" in key \"{}\"", value.getClass(), key);
        return Collections.emptySet();
    }
}
Also used : Joiner(com.google.common.base.Joiner) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 30 with Joiner

use of com.google.common.base.Joiner in project stargate-core by tuplejump.

the class IndexTestBase method pattern.

protected String pattern(String[] refs, boolean[] optional, boolean[] repeat) {
    Joiner joiner = Joiner.on(",\n");
    String template = "{ref:\"%s\",optional:\"%s\",repeat:\"%s\"}";
    List<String> steps = new ArrayList<>(refs.length);
    for (int i = 0; i < refs.length; i++) {
        steps.add(String.format(template, refs[i], optional[i], repeat[i]));
    }
    return "pattern:{steps:[\n" + joiner.join(steps) + "\n]}";
}
Also used : Joiner(com.google.common.base.Joiner)

Aggregations

Joiner (com.google.common.base.Joiner)39 ArrayList (java.util.ArrayList)8 IOException (java.io.IOException)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 BufferedWriter (java.io.BufferedWriter)3 List (java.util.List)3 ResultSet (com.google.cloud.spanner.ResultSet)2 Statement (com.google.cloud.spanner.Statement)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 DBException (com.yahoo.ycsb.DBException)2 File (java.io.File)2 URI (java.net.URI)2 Iterator (java.util.Iterator)2 LinkedList (java.util.LinkedList)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 FileLineDifferenceIterator (org.apache.jackrabbit.oak.commons.FileIOUtils.FileLineDifferenceIterator)2 CConfiguration (co.cask.cdap.common.conf.CConfiguration)1 PropertyFieldSetter (co.cask.cdap.common.lang.PropertyFieldSetter)1 DataSetFieldSetter (co.cask.cdap.internal.app.runtime.DataSetFieldSetter)1