List of usage examples for com.google.common.collect ImmutableMap of
public static <K, V> ImmutableMap<K, V> of(K k1, V v1)
From source file:controllers.Mock.java
public static F.Promise<Result> mock(final String serviceName, final int vehicleId) { final int secsDelayed = Optional.ofNullable(request().getQueryString("secsDelayed")) .map(str -> Integer.parseInt(str)).orElse(0); final boolean boom = Optional.ofNullable(request().getQueryString("boom")).map(str -> Boolean.valueOf(str)) .orElse(false);// ww w.ja va 2s . c om if (boom) { return F.Promise.throwing(new RuntimeException("boom!!!")); } if (vehicleId != 1) { return F.Promise.pure(notFound(Json.toJson(ImmutableMap.of("error", "content not found!")))); } switch (serviceName) { case "vehicleData": return respond(Json.toJson(fakeVehicleData()), secsDelayed); case "vehicleImage": return respond(Json.toJson(fakeVehicleImage()), secsDelayed); case "searchResults": return respond(Json.toJson(fakeSearchResults()), secsDelayed); default: return F.Promise.pure(badRequest(String.format("serviceName %s not supported!", serviceName))); } }
From source file:org.opendaylight.controller.netconf.util.xml.HardcodedNamespaceResolver.java
public HardcodedNamespaceResolver(String prefix, String namespace) { this(ImmutableMap.of(prefix, namespace)); }
From source file:org.glowroot.agent.PropertiesFiles.java
static void upgradeIfNeededAndLoadInto(File confDir, Map<String, String> properties) throws IOException { File propFile = new File(confDir, "glowroot.properties"); if (!propFile.exists()) { return;//from w ww.j a v a 2 s. c o m } // upgrade from 0.9.6 to 0.9.7 org.glowroot.common.util.PropertiesFiles.upgradeIfNeeded(propFile, ImmutableMap.of("agent.rollup=", "agent.rollup.id=")); // upgrade from 0.9.13 to 0.9.14 upgradeToCollectorAddressIfNeeded(propFile); // upgrade from 0.9.26 to 0.9.27 addSchemeToCollectorAddressIfNeeded(propFile); // upgrade from 0.9.28 to 0.10.0 prependAgentRollupToAgentIdIfNeeded(propFile); InputStream in = new FileInputStream(propFile); Properties props = new Properties(); try { props.load(in); } finally { in.close(); } for (String key : props.stringPropertyNames()) { String value = props.getProperty(key); if (value != null && !value.isEmpty()) { // need to trim trailing spaces (leading spaces are already trimmed during load) properties.put("glowroot." + key, value.trim()); } } }
From source file:org.marketcetera.photon.test.OSGITestUtil.java
/** * Register the provided service with the specified rank. * /*from w ww .ja va 2 s. com*/ * @param clazz * the class name under which the service can be located * @param service * the service object or a ServiceFactory object * @param rank * the rank for the service * @return the ServiceRegistration that can be used to unregister the * service */ public static ServiceRegistration registerMockService(Class<?> clazz, Object service, int rank) { return getTestBundleContext().registerService(clazz.getName(), service, new Hashtable<String, Integer>(ImmutableMap.of(Constants.SERVICE_RANKING, rank))); }
From source file:es.upm.oeg.tools.quality.ldsniffer.util.LDResourceExtractor.java
public static List<String> extractInstances(String sparqlEndpoint, String clazz) throws IOException { ArrayList<String> list = new ArrayList<>(); Map<String, String> litMap = new HashMap<>(); Map<String, String> iriMap = ImmutableMap.of("class", clazz); String queryString = bindQueryString(isntancesQuery, ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap)); List<RDFNode> nodeList = executeQueryForList(queryString, sparqlEndpoint, "s"); for (RDFNode clazzNode : nodeList) { if (clazzNode.isURIResource()) { list.add(clazzNode.asResource().getURI()); }/* www . j ava 2 s. c o m*/ } return list; }
From source file:brooklyn.test.NetworkingTestUtils.java
public static void assertPortsAvailableEventually(final Map<String, Integer> ports, final Duration timeout) { Asserts.succeedsEventually(ImmutableMap.of("timeout", Duration.minutes(4)), new Runnable() { private boolean logged = false; public void run() { try { assertPortsAvailable(ports); } catch (Throwable t) { if (!logged) { LOG.warn("Port(s) not available; waiting for up to " + timeout + " (" + Exceptions.getFirstInteresting(t) + ")"); logged = true;//from w w w . ja v a 2 s.c om } throw Exceptions.propagate(t); } } }); LOG.debug("Ports are available: " + ports); }
From source file:com.google.cloud.spanner.TraceUtil.java
static ImmutableMap<String, AttributeValue> getExceptionAnnotations(SpannerException e) { return ImmutableMap.of("Status", AttributeValue.stringAttributeValue(e.getErrorCode().toString())); }
From source file:org.apache.cassandra.schema.ReplicationParams.java
static ReplicationParams simple(int replicationFactor) { return new ReplicationParams(SimpleStrategy.class, ImmutableMap.of("replication_factor", Integer.toString(replicationFactor))); }
From source file:se.sics.caracaldb.operations.OpUtil.java
/** * Check and Set operation.//from ww w . j av a 2 s.c om * * If value@key == oldValue set value@key = newValue. * * @param k * @param oldValue * @param newValue * @return */ public static MultiOpRequest cas(UUID id, Key key, byte[] oldValue, byte[] newValue) { Condition c = new EqualCondition(key, oldValue); return new MultiOpRequest(id, ImmutableSet.of(c), ImmutableMap.of(key, newValue), ImmutableMap.copyOf(new HashMap<Key, byte[]>())); // java6 is soooooo baaaadd -.- }
From source file:com.icosilune.fnexample.simple.TimestampFn.java
@Override public Map<String, Object> evaluateWrapper(EvaluationContext context, Map<String, Object> args) { double timestamp = (Double) context.getValue("timestamp"); return ImmutableMap.of("timestamp", timestamp); }