public static HttpPost post(String uri, List<NameValuePair> formParams) { final HttpPost post = new HttpPost(uri); setFormParams(post, Collections.toArray(NameValuePair.class, formParams)); return post; }
/** * Waits for the result of a created barrier for <code>jobs</code>, using <code>registry</code> to poll for the * outcome of the monitored jobs using the default polling interval. * * @param reg * the service registry * @param timeout * the maximum amount of time to wait * @param jobs * the jobs to monitor * @return the job barrier result */ public static JobBarrier.Result waitForJobs(ServiceRegistry reg, long timeout, Collection<Job> jobs) { return waitForJobs(null, reg, timeout, toArray(Job.class, jobs)); }
/** * Waits for the result of a created barrier for <code>jobs</code>, using <code>registry</code> to poll for the * outcome of the monitored jobs using the default polling interval. The * <code>waiter</code> is the job which is waiting for the other jobs to finish. * * @param waiter * the job waiting for the other jobs to finish * @param reg * the service registry * @param jobs * the jobs to monitor * @return the job barrier result */ public static JobBarrier.Result waitForJobs(Job waiter, ServiceRegistry reg, Collection<Job> jobs) { return waitForJobs(waiter, reg, toArray(Job.class, jobs)); }
/** * Waits for the result of a created barrier for <code>jobs</code>, using <code>registry</code> to poll for the * outcome of the monitored jobs using the default polling interval. The * <code>waiter</code> is the job which is waiting for the other jobs to finish. * * @param waiter * the job waiting for the other jobs to finish * @param reg * the service registry * @param timeout * the maximum amount of time to wait * @param jobs * the jobs to monitor * @return the job barrier result */ public static JobBarrier.Result waitForJobs(Job waiter, ServiceRegistry reg, long timeout, Collection<Job> jobs) { return waitForJobs(waiter, reg, timeout, toArray(Job.class, jobs)); }
@Override public List<BundleInfoJpa> apply(EntityManager em) { final CriteriaBuilder cb = em.getCriteriaBuilder(); final CriteriaQuery<BundleInfoJpa> q = cb.createQuery(BundleInfoJpa.class); final Root<BundleInfoJpa> r = q.from(BundleInfoJpa.class); q.select(r); final Expression<String> symbolicNamePath = r.get("bundleSymbolicName"); final Predicate[] likes = toArray(Predicate.class, mlist(prefixes).map(new Function<String, Predicate>() { @Override public Predicate apply(String prefix) { return cb.like(symbolicNamePath, prefix + "%"); } }).value()); q.where(cb.or(likes)); q.orderBy(cb.asc(r.get("host")), cb.asc(symbolicNamePath)); return em.createQuery(q).getResultList(); } };
/** Run <code>f</code> if there is at least one bundle matching the given prefixes. */ private Response withBundles(List<String> prefixes, Function<List<BundleInfo>, Response> f) { final List<BundleInfo> info = getDb().getBundles(toArray(String.class, prefixes)); if (info.size() > 0) { return f.apply(info); } else { return notFound("No bundles match one of the given prefixes"); } } }
public static RestServiceTestEnv testEnvScanPackages(URL baseUrl, Package... servicePkgs) { return new RestServiceTestEnv(baseUrl, some(new PackagesResourceConfig(toArray(String.class, mlist(servicePkgs).map(pkgName).value())))); }