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));
}
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;
}
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()));
}
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();
}
}
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]}";
}
Aggregations