method2testcases stringlengths 118 6.63k |
|---|
### Question:
PeriodicWatch extends ThresholdWatch implements PeriodicWatchMBean { public long getPeriod() { return (period); } PeriodicWatch(String id); PeriodicWatch(String id, Configuration config); PeriodicWatch(WatchDataSource watchDataSource, String id); void start(); void stop(); long getPeriod(); void setPeri... |
### Question:
PeriodicWatch extends ThresholdWatch implements PeriodicWatchMBean { public void setPeriod(long newPeriod) { if(newPeriod == period) return; if(newPeriod <= 0) throw new IllegalArgumentException("period cannot be less then or equal to zero"); this.period = newPeriod; if(watchTimer!=null) { stop(); start()... |
### Question:
PeriodicWatch extends ThresholdWatch implements PeriodicWatchMBean { public void start() { long now = System.currentTimeMillis(); stop(); watchTimer = new Timer(true); watchTimer.schedule(new PeriodicTask(), new Date(now+period), period); } PeriodicWatch(String id); PeriodicWatch(String id, Configuration... |
### Question:
PeriodicWatch extends ThresholdWatch implements PeriodicWatchMBean { public void stop() { if(watchTimer != null) watchTimer.cancel(); } PeriodicWatch(String id); PeriodicWatch(String id, Configuration config); PeriodicWatch(WatchDataSource watchDataSource, String id); void start(); void stop(); long get... |
### Question:
Statistics { public void setValues(Iterable<Double> vals) { if(vals==null) throw new IllegalArgumentException("vector is null"); v.clear(); for(Double d : vals) v.add(d); } Statistics(); Statistics(Iterable<Double> values); void clearAll(); int count(); double max(); double min(); double mean(); double m... |
### Question:
GaugeWatch extends ThresholdWatch { public void addValue(long value) { addWatchRecord(new Calculable(id, (double)value, System.currentTimeMillis())); } GaugeWatch(String id); GaugeWatch(String id, Configuration config); GaugeWatch(WatchDataSource watchDataSource, String id); void addValue(long value); v... |
### Question:
WatchDataSourceRegistry implements WatchRegistry { public void closeAll() { Watch[] watches = watchRegistry.toArray(new Watch[0]); for(Watch w : watches) { if(w instanceof PeriodicWatch) ((PeriodicWatch)w).stop(); try { WatchDataSource wd = w.getWatchDataSource(); if (wd != null) wd.close(); watchRegistry... |
### Question:
WatchDataSourceRegistry implements WatchRegistry { public Watch findWatch(String id) { if(id == null) throw new IllegalArgumentException("id is null"); Watch watch = null; for(Watch w : watchRegistry) { if(id.equals(w.getId())) { watch = w; break; } } return watch; } void deregister(Watch... watches); vo... |
### Question:
WatchDataSourceRegistry implements WatchRegistry { public void addThresholdListener(String id, ThresholdListener thresholdListener) { if(id==null) throw new IllegalArgumentException("id is null"); if(thresholdListener==null) throw new IllegalArgumentException("thresholdListener is null"); Collection<Thres... |
### Question:
ConfigHelper { public static String[] getConfigArgs(final ServiceElement service) throws IOException { return getConfigArgs(service, Thread.currentThread().getContextClassLoader()); } static String[] getConfigArgs(final ServiceElement service); static String[] getConfigArgs(final ServiceElement service, ... |
### Question:
ClassBundleLoader { public static Class<?> loadClass(ClassBundle bundle) throws ClassNotFoundException, MalformedURLException { Class<?> theClass; final Thread currentThread = Thread.currentThread(); final ClassLoader cCL = AccessController.doPrivileged( (PrivilegedAction<ClassLoader>) currentThread::getC... |
### Question:
Statistics { public void removeValue(int location) { if(location < v.size() && location >= 0) v.removeElementAt(location); } Statistics(); Statistics(Iterable<Double> values); void clearAll(); int count(); double max(); double min(); double mean(); double median(); double mode(); int modeOccurrenceCount(... |
### Question:
AssociationInjector implements AssociationListener<T> { public void discovered(Association<T> association, T service) { inject(association, service); } AssociationInjector(Object target); void setBackend(Object target); void setCallerClassLoader(ClassLoader callerCL); void terminate(); Map<AssociationDesc... |
### Question:
AssociationInjector implements AssociationListener<T> { public void setBackend(Object target) { this.target = target; } AssociationInjector(Object target); void setBackend(Object target); void setCallerClassLoader(ClassLoader callerCL); void terminate(); Map<AssociationDescriptor, Long> getInvocationMap()... |
### Question:
AssociationProxyUtil { public static <T> Association<T> getAssociation(T proxy) { Association<T> association = null; if(proxy instanceof AssociationProxy) { association = ((AssociationProxy<T>)proxy).getAssociation(); } return association; } static T getService(T proxy); static T regenProxy(T proxy); sta... |
### Question:
AssociationProxyUtil { public static <T> T regenProxy(T proxy) throws ClassNotFoundException, InstantiationException, IllegalAccessException { T newProxy = null; if(proxy instanceof AssociationProxy) { AssociationProxy<T> aProxy = (AssociationProxy)proxy; Association<T> association = aProxy.getAssociation... |
### Question:
ComputeResourceAccessor { public static ComputeResource getComputeResource() { if(computeResource==null) { try { computeResource = new ComputeResource(); computeResource.boot(); } catch (ConfigurationException | UnknownHostException e) { logger.error("Unable to create default ComputeResource", e); } } ret... |
### Question:
SystemCapabilities implements SystemCapabilitiesLoader { public MeasurableCapability[] getMeasurableCapabilities(Configuration config) { if(config==null) throw new IllegalArgumentException("config is null"); List<MeasurableCapability> measurables = new ArrayList<>(); MeasurableCapability memory = new Memo... |
### Question:
Jetty implements WebsterService { public int getPort() { if (server == null) { return port; } return ((ServerConnector)server.getConnectors()[0]).getLocalPort(); } Jetty(); Jetty(File jettyConfig); Jetty(Configuration config); Jetty setRoots(String... roots); Jetty setPort(int port); Jetty setMinThreads... |
### Question:
GenericCostModel implements ResourceCostModel { public GenericCostModel(double value) { this(value, null, DEFAULT_DESCRIPTION); } GenericCostModel(double value); GenericCostModel(double value, TimeBoundary[] timeBoundaries); GenericCostModel(double value,
TimeBoundary[] time... |
### Question:
BasicEventConsumer implements EventConsumer, ServerProxyTrust { public boolean register(final RemoteServiceEventListener listener) { return (register(listener, null)); } BasicEventConsumer(final EventDescriptor edTemplate); BasicEventConsumer(final RemoteServiceEventListener<?> listener); BasicEventCons... |
### Question:
EventDescriptorFactory { public static List<EventDescriptor> createEventDescriptors(String classpath, String... classNames) throws MalformedURLException, ResolverException, ClassNotFoundException, URISyntaxException { if(classNames==null) throw new IllegalArgumentException("classNames must not be null"); ... |
### Question:
Version { public boolean isRange() { return version.contains(","); } Version(final String version); boolean isRange(); String getVersion(); String getStartRange(); String getEndRange(); boolean minorVersionSupport(); boolean majorVersionSupport(); @Override boolean equals(Object o); @Override int hashCode... |
### Question:
Version { public String getVersion() { if (minorVersionSupport() || majorVersionSupport()) { return version.substring(0, version.length()-1).trim(); } return version.trim(); } Version(final String version); boolean isRange(); String getVersion(); String getStartRange(); String getEndRange(); boolean minor... |
### Question:
Version { public String getStartRange() { String[] parts = version.split(",", 2); return parts[0].trim(); } Version(final String version); boolean isRange(); String getVersion(); String getStartRange(); String getEndRange(); boolean minorVersionSupport(); boolean majorVersionSupport(); @Override boolean e... |
### Question:
Version { public String getEndRange() { if (!isRange()) return getVersion(); String[] parts = version.split(",", 2); return parts[1].trim(); } Version(final String version); boolean isRange(); String getVersion(); String getStartRange(); String getEndRange(); boolean minorVersionSupport(); boolean majorVe... |
### Question:
Version { public boolean minorVersionSupport() { return version.endsWith("*"); } Version(final String version); boolean isRange(); String getVersion(); String getStartRange(); String getEndRange(); boolean minorVersionSupport(); boolean majorVersionSupport(); @Override boolean equals(Object o); @Override ... |
### Question:
Jetty implements WebsterService { @Override public void start() throws Exception { createServer(); ServerConnector connector = new ServerConnector(server); connector.setPort(port); String address = HostUtil.getHostAddressFromProperty("java.rmi.server.hostname"); connector.setHost(address); server.setConne... |
### Question:
Version { public boolean majorVersionSupport() { return version.endsWith("+"); } Version(final String version); boolean isRange(); String getVersion(); String getStartRange(); String getEndRange(); boolean minorVersionSupport(); boolean majorVersionSupport(); @Override boolean equals(Object o); @Override ... |
### Question:
Version { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Version version1 = (Version) o; return version.equals(version1.version); } Version(final String version); boolean isRange(); String getVersion(); String getS... |
### Question:
RioProperties { public static void load() { File rioEnv; String rioEnvFileName = System.getProperty(Constants.ENV_PROPERTY_NAME, System.getenv(Constants.ENV_PROPERTY_NAME)); if(rioEnvFileName==null) { File rioRoot = new File(System.getProperty("user.home"), ".rio"); rioEnv = new File(rioRoot, "rio.env"); ... |
### Question:
InstantiatorResource { boolean meetsGeneralRequirements(final ProvisionRequest provisionRequest) { ServiceElement sElem = provisionRequest.getServiceElement(); String[] machineCluster = sElem.getCluster(); if (machineCluster != null && machineCluster.length > 0) { logger.debug("ServiceBean [{}] has a clus... |
### Question:
SettingsUtil { public static Settings getSettings() throws SettingsBuildingException { DefaultSettingsBuilder defaultSettingsBuilder = new DefaultSettingsBuilder(); DefaultSettingsBuildingRequest request = new DefaultSettingsBuildingRequest(); File userSettingsFile = new File(System.getProperty("user.home... |
### Question:
NettyAllocatorMetricSet implements MetricSet { @Override public Map<String, Metric> getMetrics() { Map<String, Metric> gauges = new HashMap<>(); gauges.put(name(namespace, "usedDirectMemory"), (Gauge<Long>) metric::usedDirectMemory); gauges.put(name(namespace, "usedHeapMemory"), (Gauge<Long>) metric::used... |
### Question:
StartupConfig { public static StartupConfig load() { String styxHome = System.getProperty(STYX_HOME_VAR_NAME); checkArgument(styxHome != null, "No system property %s has been defined.", STYX_HOME_VAR_NAME); checkArgument(isReadable(Paths.get(styxHome)), "%s=%s is not a readable configuration path.", STYX_... |
### Question:
JsonTreeTraversal { public static <T extends JsonTreeVisitor> T traverseJsonTree(JsonNode node, T visitor) { traverseJsonTree(node, null, new ArrayList<>(), visitor); return visitor; } static T traverseJsonTree(JsonNode node, T visitor); }### Answer:
@Test public void canTraverseValueNodesInOrder() thro... |
### Question:
YamlConfigurationFormat implements ConfigurationFormat<YamlConfiguration> { @Override public String resolvePlaceholdersInText(String text, Map<String, String> overrides) { List<PlaceholderResolver.Placeholder> placeholders = extractPlaceholders(text); String resolvedText = text; for (PlaceholderResolver.P... |
### Question:
PlaceholderResolver { @VisibleForTesting static List<String> extractPlaceholderStrings(String value) { Matcher matcher = PLACEHOLDER_REGEX_CAPTURE_ALL.matcher(value); List<String> placeholders = new ArrayList<>(); while (matcher.find()) { placeholders.add(matcher.group()); } return placeholders; } Placeho... |
### Question:
PlaceholderResolver { @VisibleForTesting public static List<Placeholder> extractPlaceholders(String value) { List<Placeholder> namesAndDefaults = new ArrayList<>(); for (String placeholder : extractPlaceholderStrings(value)) { Matcher placeholderMatcher = PLACEHOLDER_REGEX_CAPTURE_NAME_AND_DEFAULT.matcher... |
### Question:
PlaceholderResolver { @VisibleForTesting public static String replacePlaceholder(String originalString, String placeholderName, String placeholderValue) { return originalString.replaceAll("\\$\\{" + quote(placeholderName) + "(?:\\:[^\\}]*?)?\\}", placeholderValue); } PlaceholderResolver(ObjectNode rootNod... |
### Question:
NodePath { public Optional<JsonNode> findMatchingDescendant(JsonNode rootNode) { JsonNode current = rootNode; for (PathElement element : elements) { current = element.child(current); if (current == null) { return Optional.empty(); } } return Optional.ofNullable(current); } NodePath(String path); NodePat... |
### Question:
JsonNodeConfig implements Configuration { @Override public Optional<String> get(String key) { return get(key, String.class); } JsonNodeConfig(JsonNode rootNode); protected JsonNodeConfig(JsonNode rootNode, ObjectMapper mapper); @Override Optional<String> get(String key); @Override Optional<T> get(String ... |
### Question:
ConfigurationParser { public C parse(ConfigurationSource provider) { LOGGER.debug("Parsing configuration in format={} from source={}", format, provider); C configuration = doParse(provider).withOverrides(overrides); PlaceholderResolutionResult<C> resolved = configuration.resolvePlaceholders(overrides); if... |
### Question:
GraphiteReporter extends ScheduledReporter { @VisibleForTesting void initConnection() { tryTimes( MAX_RETRIES, graphite::connect, (e) -> attemptErrorHandling(graphite::close) ); } private GraphiteReporter(MetricRegistry registry,
GraphiteSender graphite,
... |
### Question:
MemoryBackedRegistry extends AbstractRegistry<T> { public void add(T t) { resources.put(t.id(), t); if (autoReload) { reload(); } } MemoryBackedRegistry(); private MemoryBackedRegistry(boolean autoReload); void add(T t); void removeById(Id id); void reset(); @Override CompletableFuture<ReloadResult> relo... |
### Question:
ExceptionConverter extends ClassicConverter { @Override public String convert(final ILoggingEvent loggingEvent) { return Optional.ofNullable(loggingEvent) .map(this::getExceptionData) .orElse(NO_MSG); } @Override String convert(final ILoggingEvent loggingEvent); static final String TARGET_CLASSES_PROPERT... |
### Question:
LOGBackConfigurer { public static void initLogging(String logConfigLocation, boolean installJULBridge) { try { String location = resolvePlaceholders(logConfigLocation); if (location.indexOf("${") >= 0) { throw new IllegalStateException("unable to resolve certain placeholders: " + sanitise(location)); } lo... |
### Question:
StyxConfig implements Configuration { public ProxyServerConfig proxyServerConfig() { return proxyServerConfig; } StyxConfig(); StyxConfig(Configuration configuration); @Override Optional<T> get(String key, Class<T> tClass); @Override X as(Class<X> type); @Override Optional<String> get(String key); StyxHe... |
### Question:
YamlApplicationsProvider { public static YamlApplicationsProvider loadFromPath(String path) { return new YamlApplicationsProvider(newResource(path)); } private YamlApplicationsProvider(String yamlText); YamlApplicationsProvider(Resource resource); static YamlApplicationsProvider loadFromPath(String path... |
### Question:
ServiceProvision { public static <E extends RetryPolicy> Optional<E> loadRetryPolicy( Configuration configuration, Environment environment, String key, Class<? extends E> serviceClass) { return configuration .get(key, ServiceFactoryConfig.class) .map(factoryConfig -> { RetryPolicyFactory factory = newInst... |
### Question:
ServiceProvision { public static <T> Map<String, T> loadServices(Configuration configuration, Environment environment, String key, Class<? extends T> serviceClass) { return configuration.get(key, JsonNode.class) .<Map<String, T>>map(node -> servicesMap(node, environment, serviceClass)) .orElse(emptyMap())... |
### Question:
StyxServer extends AbstractService { public InetSocketAddress proxyHttpAddress() { return Optional.ofNullable(httpServer) .map(InetServer::inetAddress) .orElse(null); } StyxServer(StyxServerComponents config); StyxServer(StyxServerComponents components, Stopwatch stopwatch); static void main(String[] arg... |
### Question:
StyxServer extends AbstractService { public static void main(String[] args) { try { StyxServer styxServer = createStyxServer(args); getRuntime().addShutdownHook(new Thread(() -> styxServer.stopAsync().awaitTerminated())); styxServer.startAsync().awaitRunning(); } catch (SchemaValidationException cause) { ... |
### Question:
ResponseInfoFormat { public String format(LiveHttpRequest request) { return String.format(format, request == null ? "" : request.id()); } ResponseInfoFormat(Environment environment); String format(LiveHttpRequest request); }### Answer:
@Test public void defaultFormatDoesNotIncludeVersion() { String info ... |
### Question:
SpiExtension { public JsonNode config() { return config; } @JsonCreator SpiExtension(@JsonProperty("factory") SpiExtensionFactory factory,
@JsonProperty("config") JsonNode config,
@JsonProperty("enabled") Boolean enabled); SpiExtensionFactory factory(); Jso... |
### Question:
ExtensionObjectFactory { public <T> T newInstance(SpiExtensionFactory extensionFactory, Class<T> type) throws ExtensionLoadingException { try { Class<?> extensionClass = loadClass(extensionFactory); Object instance = extensionClass.newInstance(); return type.cast(instance); } catch (ExtensionLoadingExcept... |
### Question:
PluginListHandler implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { Stream<NamedPlugin> enabled = plugins.stream().filter(NamedPlugin::enabled); Stream<NamedPlugin> disabled = plugins.stream().filter(plugin -> !plugin.enab... |
### Question:
JsonReformatter { public static String reformat(String json) { try { return reformat0(json); } catch (IOException e) { throw new RuntimeException(e); } } private JsonReformatter(); static String reformat(String json); }### Answer:
@Test public void splitsUpDotsIfTheyAreCommonBetweenKeysInSameObject() { ... |
### Question:
ServiceProviderHandler implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { return urlRouter.handle(request, context); } ServiceProviderHandler(StyxObjectStore<StyxObjectRecord<StyxService>> providerDatabase); @Override Event... |
### Question:
MetricsHandler implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { return this.urlMatcher.handle(request, context); } MetricsHandler(MetricRegistry metricRegistry, Optional<Duration> cacheExpiration); @Override Eventual<Http... |
### Question:
ProviderListHandler implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { String providerList = providerDb.entrySet().stream() .map(entry -> htmlForProvider(entry.getKey(), entry.getValue())) .collect(joining()); String html =... |
### Question:
LoggingConfigurationHandler implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { return Eventual.of(generateResponse()); } LoggingConfigurationHandler(Resource logConfigLocation); @Override Eventual<HttpResponse> handle(HttpR... |
### Question:
OriginsReloadCommandHandler implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { return new Eventual<>(Flux.create(this::reload) .subscribeOn(Schedulers.fromExecutor(executor))); } OriginsReloadCommandHandler(Registry<Backend... |
### Question:
DashboardData { @JsonProperty("server") public Server server() { return server; } DashboardData(MetricRegistry metrics, Registry<BackendService> backendServicesRegistry, String serverId, Version version, EventBus eventBus); @JsonProperty("server") Server server(); @JsonProperty("downstream") Downstream do... |
### Question:
DashboardData { void unregister() { this.downstream.unregister(); } DashboardData(MetricRegistry metrics, Registry<BackendService> backendServicesRegistry, String serverId, Version version, EventBus eventBus); @JsonProperty("server") Server server(); @JsonProperty("downstream") Downstream downstream(); @J... |
### Question:
DashboardDataSupplier implements Supplier<DashboardData>, Registry.ChangeListener<BackendService> { @Override public DashboardData get() { return data; } DashboardDataSupplier(Registry<BackendService> backendServicesRegistry, Environment environment, StyxConfig styxConfig); @Override void onChange(Registr... |
### Question:
SimpleConverter implements Converter { @Override public <T> T convert(Object source, Class<T> targetType) { if (source == null) { return null; } if (targetType == Boolean.class || targetType == Boolean.TYPE) { @SuppressWarnings("unchecked") T t = (T) Boolean.valueOf(source.toString()); return t; } @Suppre... |
### Question:
HttpHeaders implements Iterable<HttpHeader> { public Set<String> names() { return ImmutableSet.copyOf(nettyHeaders.names()); } private HttpHeaders(Builder builder); Set<String> names(); Optional<String> get(CharSequence name); List<String> getAll(CharSequence name); boolean contains(CharSequence name); @... |
### Question:
HttpHeaders implements Iterable<HttpHeader> { public boolean contains(CharSequence name) { return nettyHeaders.contains(name); } private HttpHeaders(Builder builder); Set<String> names(); Optional<String> get(CharSequence name); List<String> getAll(CharSequence name); boolean contains(CharSequence name);... |
### Question:
HttpHeaders implements Iterable<HttpHeader> { public Optional<String> get(CharSequence name) { return Optional.ofNullable(nettyHeaders.get(name)); } private HttpHeaders(Builder builder); Set<String> names(); Optional<String> get(CharSequence name); List<String> getAll(CharSequence name); boolean contains... |
### Question:
HttpHeaders implements Iterable<HttpHeader> { @Override public String toString() { return Iterables.toString(nettyHeaders); } private HttpHeaders(Builder builder); Set<String> names(); Optional<String> get(CharSequence name); List<String> getAll(CharSequence name); boolean contains(CharSequence name); @O... |
### Question:
LiveHttpResponse implements LiveHttpMessage { public static Builder response() { return new Builder(); } LiveHttpResponse(Builder builder); static Builder response(); static Builder response(HttpResponseStatus status); static Builder response(HttpResponseStatus status, ByteStream body); @Override HttpHead... |
### Question:
ServerCookieEncoder extends CookieEncoder { String encode(String name, String value) { return encode(new DefaultCookie(name, value)); } private ServerCookieEncoder(boolean strict); }### Answer:
@Test public void removesMaxAgeInFavourOfExpireIfDateIsInThePast() { String cookieValue = "hp_pos=\"\"; Domai... |
### Question:
ResponseCookie { private ResponseCookie(Builder builder) { if (builder.name == null || builder.name.isEmpty()) { throw new IllegalArgumentException(); } this.name = builder.name; this.value = builder.value; this.domain = builder.domain; this.maxAge = builder.maxAge; this.path = builder.path; this.httpOnly... |
### Question:
HttpHeader { public static HttpHeader header(String name, String... values) { if (values.length <= 0) { throw new IllegalArgumentException("must give at least one value"); } return new HttpHeader(requireNonNull(name), ImmutableList.copyOf(values)); } private HttpHeader(String name, List<String> values); ... |
### Question:
Eventual implements Publisher<T> { public static <T> Eventual<T> from(CompletionStage<T> completionStage) { return fromMono(Mono.fromCompletionStage(completionStage)); } Eventual(Publisher<T> publisher); static Eventual<T> of(T value); static Eventual<T> from(CompletionStage<T> completionStage); static Ev... |
### Question:
Eventual implements Publisher<T> { public static <T> Eventual<T> of(T value) { return fromMono(Mono.just(value)); } Eventual(Publisher<T> publisher); static Eventual<T> of(T value); static Eventual<T> from(CompletionStage<T> completionStage); static Eventual<T> error(Throwable error); Eventual<R> map(Func... |
### Question:
Eventual implements Publisher<T> { public static <T> Eventual<T> error(Throwable error) { return fromMono(Mono.error(error)); } Eventual(Publisher<T> publisher); static Eventual<T> of(T value); static Eventual<T> from(CompletionStage<T> completionStage); static Eventual<T> error(Throwable error); Eventual... |
### Question:
IoRetry { public static void tryTimes(int times, IOAction task, Consumer<IOException> errorHandler) throws UncheckedIOException, IllegalArgumentException { if (times < 1) { throw new IllegalArgumentException("The number of retries should be a positive integer. It was " + times); } int retries = 0; while (... |
### Question:
Eventual implements Publisher<T> { public <R> Eventual<R> map(Function<? super T, ? extends R> transformation) { return fromMono(Mono.from(publisher).map(transformation)); } Eventual(Publisher<T> publisher); static Eventual<T> of(T value); static Eventual<T> from(CompletionStage<T> completionStage); stati... |
### Question:
HttpMessageSupport { public static boolean chunked(HttpHeaders headers) { for (String value : headers.getAll(TRANSFER_ENCODING)) { if (value.equalsIgnoreCase(CHUNKED.toString())) { return true; } } return false; } private HttpMessageSupport(); static boolean chunked(HttpHeaders headers); static boolean k... |
### Question:
HttpMessageSupport { public static boolean keepAlive(HttpHeaders headers, HttpVersion version) { Optional<String> connection = headers.get(CONNECTION); if (connection.isPresent()) { if (CLOSE.toString().equalsIgnoreCase(connection.get())) { return false; } if (KEEP_ALIVE.toString().equalsIgnoreCase(connec... |
### Question:
LiveHttpRequest implements LiveHttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } LiveHttpRequest(Builder builder); static Builder get(String uri); static Builder head(String uri); static Builder post(String uri); static Builder delete(String uri); static Builder put(Str... |
### Question:
LiveHttpRequest implements LiveHttpMessage { public static Builder post(String uri) { return new Builder(POST, uri); } LiveHttpRequest(Builder builder); static Builder get(String uri); static Builder head(String uri); static Builder post(String uri); static Builder delete(String uri); static Builder put(S... |
### Question:
HttpRequest implements HttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } HttpRequest(Builder builder); static Builder get(String uri); static Builder head(String uri); static Builder post(String uri); static Builder delete(String uri); static Builder put(String uri); st... |
### Question:
HttpRequest implements HttpMessage { public static Builder post(String uri) { return new Builder(POST, uri); } HttpRequest(Builder builder); static Builder get(String uri); static Builder head(String uri); static Builder post(String uri); static Builder delete(String uri); static Builder put(String uri); ... |
### Question:
RewriteConfig implements RewriteRule { @Override public Optional<String> rewrite(String originalUri) { Matcher matcher = compiledUrlPattern.matcher(originalUri); if (matcher.matches()) { return Optional.of(preprocessedReplacement.substitute(matcher)); } return Optional.empty(); } RewriteConfig(String urlP... |
### Question:
AbstractStyxService implements StyxService { @Override public Map<String, HttpHandler> adminInterfaceHandlers() { return ImmutableMap.of("status", (request, context) -> Eventual.of( response(OK) .addHeader(CONTENT_TYPE, APPLICATION_JSON) .body(format("{ name: \"%s\" status: \"%s\" }", name, status), UTF_8... |
### Question:
HttpResponse implements HttpMessage { public static Builder response() { return new Builder(); } private HttpResponse(Builder builder); static Builder response(); static Builder response(HttpResponseStatus status); @Override Optional<String> header(CharSequence name); @Override List<String> headers(CharS... |
### Question:
GraphiteReporter extends ScheduledReporter { @Override public void stop() { try { super.stop(); } finally { try { graphite.close(); } catch (IOException e) { LOGGER.debug("Error disconnecting from Graphite", e); } } } private GraphiteReporter(MetricRegistry registry,
Graphite... |
### Question:
UrlQuery { String encodedQuery() { return encodedQuery; } private UrlQuery(List<Parameter> parameters); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test public void providesEncodedQuery() { assertThat(query.encodedQuery(), is("foo=alpha&bar=be... |
### Question:
UrlQuery { Iterable<String> parameterNames() { return parameters().stream().map(Parameter::key).distinct().collect(toList()); } private UrlQuery(List<Parameter> parameters); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test public void provides... |
### Question:
UrlQuery { Optional<String> parameterValue(String name) { return stream(parameterValues(name).spliterator(), false).findFirst(); } private UrlQuery(List<Parameter> parameters); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test public void provi... |
### Question:
UrlQuery { Iterable<String> parameterValues(String name) { return parameters().stream() .filter(parameter -> parameter.key.equals(name)) .map(Parameter::value) .collect(toList()); } private UrlQuery(List<Parameter> parameters); @Override boolean equals(Object o); @Override int hashCode(); @Override Strin... |
### Question:
UrlQuery { List<Parameter> parameters() { return parameters; } private UrlQuery(List<Parameter> parameters); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test public void providesFullParameters() { assertThat(query.parameters(), contains( new P... |
### Question:
UrlQuery { Builder newBuilder() { return new Builder(this); } private UrlQuery(List<Parameter> parameters); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test public void buildsNewQueryFromExistingQuery() { assertThat(query.newBuilder().build(),... |
### Question:
RequestCookie { private RequestCookie(String name, String value) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("name cannot be null or empty"); } requireNonNull(value, "value cannot be null"); this.name = name; this.value = value; this.hashCode = Objects.hash(name, value); } p... |
### Question:
RouteHandlerAdapter implements RoutingObject { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { return router.route(request, context) .map(handler -> handler.handle(request, context)) .orElseGet(() -> Eventual.error(new NoServiceConfiguredExcep... |
### Question:
Url implements Comparable<Url> { private Url(Builder builder) { this.scheme = builder.scheme; this.authority = builder.authority; this.path = builder.path; this.query = Optional.ofNullable(builder.queryBuilder).map(UrlQuery.Builder::build); this.fragment = builder.fragment; } private Url(Builder builder)... |
### Question:
Requests { public static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action) { return request.newBuilder() .body(it -> it.doOnEnd(action)) .build(); } private Requests(); static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action); ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.