method2testcases stringlengths 118 6.63k |
|---|
### Question:
Condition implements Internal<Condition<S, T>, T> { public Logger<Condition<S, T>, T> log(Object tag) { return new Logger<>(this, sourceProxy.getConfiguration(), tag); } private Condition(S source, Predicate<T> predicate, boolean negateExpression); S then(Consumer<T> action); S invoke(Action action); Opt... |
### Question:
Collector implements
Internal<Collector<T>, List<T>>,
And<T>,
Monad<List<T>>,
Functor<T> { @Override public Collector<T> and(T item) { if (item != null) { items.add(item); } return copy(); } Collector(InternalConfiguration configuration); @Override Collector<T> and(T item);... |
### Question:
Collector implements
Internal<Collector<T>, List<T>>,
And<T>,
Monad<List<T>>,
Functor<T> { public Logger<Collector<T>, List<T>> log(Object tag) { return new Logger<>(this, configuration, tag); } Collector(InternalConfiguration configuration); @Override Collector<T> and(T it... |
### Question:
Guard implements Internal<Guard<S, T>, T> { public static <T> Guard<Chain<T>, T> call(@NonNull Callable<T> callable) { return new Guard<>(new Chain<T>(null, InternalConfiguration.getInstance(null)).access(), callable); } private Guard(Proxy<S, T> proxy, Exception error); Guard(Proxy<S, T> proxy, Callab... |
### Question:
IsEqualComparator implements BiPredicate<T, T> { @Override public boolean test(T leftItem, T rightItem) { return (leftItem == null && rightItem == null) || (leftItem != null && leftItem.equals(rightItem)); } @Override boolean test(T leftItem, T rightItem); }### Answer:
@Test public void testWithNullFirs... |
### Question:
Optional implements
Conditional<Optional<T>, T>,
Internal<Optional<T>, T>,
Function<Consumer<T>, Optional<T>>,
DefaultIfEmpty<T>,
Functor<T> { public Optional<T> debug(Consumer<T> action) { if (chain.configuration.isDebugging() && chain.item != null) { Invoker.invok... |
### Question:
Lazy implements Callable<T>, Monad<T>, Functor<T>, Function<Consumer<T>, Lazy<T>> { public static <T, P> Lazy<T> defer(Function<P, T> delayedInitializer, P parameter) { return new Lazy<>(Curry.toCallable(delayedInitializer, parameter)); } Lazy(Callable<T> delayedAction); static Lazy<T> defer(Function<P, T... |
### Question:
InOperator implements Predicate<T> { @Override public boolean test(T item) { return item != null && !collection.isEmpty() && new Chain<>(collection, configuration) .apply(removeNulls()) .flatMap(toObservableFromIterable()) .any(hasComparatorTestPassed(item)) .blockingGet(); } InOperator(Collection<T> coll... |
### Question:
Chain implements
Conditional<Chain<T>, T>,
Internal<Chain<T>, T>,
Callable<T>,
Function<Consumer<T>, Chain<T>>,
DefaultIfEmpty<T>,
And<T>,
Monad<T>,
Functor<T> { public static <T> Chain<T> call(@NonNull Callable<T> callable) { return new Chai... |
### Question:
Chain implements
Conditional<Chain<T>, T>,
Internal<Chain<T>, T>,
Callable<T>,
Function<Consumer<T>, Chain<T>>,
DefaultIfEmpty<T>,
And<T>,
Monad<T>,
Functor<T> { public Chain<T> debug(Consumer<T> action) { if (configuration.isDebugging()) { I... |
### Question:
RootContext { public boolean isRooted() { return root.getState() == Root.State.ROOTED; } RootContext(Root root, SuBinary suBinary, SuApp suApp, SELinux seLinux, ContextSwitch contextSwitch); boolean isRooted(); Root getRoot(); SuBinary getSuBinary(); SuApp getSuApp(); SELinux getSELinux(); ContextSwitch g... |
### Question:
SuBinary { @NonNull public Type getType() { return type; } SuBinary(Type type, @Nullable String path, @Nullable String version, @Nullable String extra, List<String> raw); @NonNull Type getType(); @Nullable String getPath(); String getExtra(); @Nullable String getVersion(); List<String> getRaw(); @Override... |
### Question:
SuBinary { @Override public int hashCode() { int result = type.hashCode(); result = 31 * result + (path != null ? path.hashCode() : 0); result = 31 * result + (extra != null ? extra.hashCode() : 0); result = 31 * result + (version != null ? version.hashCode() : 0); result = 31 * result + (raw != null ? ra... |
### Question:
LineReader { @SuppressLint("NewApi") public static String getLineSeparator() { if (ApiWrap.hasKitKat()) return System.lineSeparator(); else return System.getProperty("line.separator", "\n"); } LineReader(); LineReader(String lineSeparator); @SuppressLint("NewApi") static String getLineSeparator(); String... |
### Question:
LineReader { public String readLine(Reader reader) throws IOException { char curChar; int val; StringBuilder sb = new StringBuilder(40); while ((val = reader.read()) != -1) { curChar = (char) val; if (curChar == '\n' && lineSeparator.length == 1 && curChar == lineSeparator[0]) { return sb.toString(); } el... |
### Question:
RxShell { public synchronized Single<Session> open() { if (RXSDebug.isDebug()) Timber.tag(TAG).v("open()"); if (session == null) { session = rxProcess.open() .map(session -> { OutputStreamWriter writer = new OutputStreamWriter(session.input(), StandardCharsets.UTF_8); return new Session(session, writer); ... |
### Question:
RxShell { public synchronized Single<Boolean> isAlive() { if (RXSDebug.isDebug()) Timber.tag(TAG).v("isAlive()"); if (session == null) return Single.just(false); else return session.flatMap(Session::isAlive); } RxShell(RxProcess rxProcess); synchronized Single<Session> open(); synchronized Single<Boolean>... |
### Question:
RootContext { public ContextSwitch getContextSwitch() { return contextSwitch; } RootContext(Root root, SuBinary suBinary, SuApp suApp, SELinux seLinux, ContextSwitch contextSwitch); boolean isRooted(); Root getRoot(); SuBinary getSuBinary(); SuApp getSuApp(); SELinux getSELinux(); ContextSwitch getContext... |
### Question:
RxShell { public synchronized Completable cancel() { if (RXSDebug.isDebug()) Timber.tag(TAG).v("cancel()"); if (session == null) return Completable.complete(); else return session.flatMapCompletable(Session::cancel); } RxShell(RxProcess rxProcess); synchronized Single<Session> open(); synchronized Single<... |
### Question:
RxShell { public synchronized Single<Integer> close() { if (RXSDebug.isDebug()) Timber.tag(TAG).v("close()"); if (session == null) return Single.just(0); else return session.flatMap(Session::close); } RxShell(RxProcess rxProcess); synchronized Single<Session> open(); synchronized Single<Boolean> isAlive()... |
### Question:
RxCmdShell { public synchronized Single<Session> open() { if (RXSDebug.isDebug()) Timber.tag(TAG).v("open()"); if (session == null) { session = Single .create((SingleOnSubscribe<Session>) emitter -> rxShell.open().subscribe(new SingleObserver<RxShell.Session>() { @Override public void onSubscribe(Disposab... |
### Question:
RxCmdShell { public synchronized Completable cancel() { if (RXSDebug.isDebug()) Timber.tag(TAG).v("cancel()"); if (session == null) return Completable.complete(); else return session.flatMapCompletable(Session::cancel); } @SuppressWarnings("unused") private RxCmdShell(); RxCmdShell(Builder builder, RxS... |
### Question:
RxCmdShell { public synchronized Single<Integer> close() { if (RXSDebug.isDebug()) Timber.tag(TAG).v("close()"); if (session == null) return Single.just(Cmd.ExitCode.OK); else return session.flatMap(Session::close); } @SuppressWarnings("unused") private RxCmdShell(); RxCmdShell(Builder builder, RxShell... |
### Question:
CmdProcessor { public Observable<Boolean> isIdle() { return idlePub.doOnEach(n -> { if (RXSDebug.isDebug()) Timber.tag(TAG).v("isIdle: %s", n);}); } CmdProcessor(Harvester.Factory factory); Single<Cmd.Result> submit(Cmd cmd); synchronized void attach(RxShell.Session session); Observable<Boolean> isIdle();... |
### Question:
SuApp { @Override public int hashCode() { int result = type.hashCode(); result = 31 * result + (packageName != null ? packageName.hashCode() : 0); result = 31 * result + (versionName != null ? versionName.hashCode() : 0); result = 31 * result + (versionCode != null ? versionCode.hashCode() : 0); result = ... |
### Question:
RootKiller implements ProcessKiller { public boolean kill(Process process) { if (RXSDebug.isDebug()) Timber.tag(TAG).d("kill(%s)", process); if (!ProcessHelper.isAlive(process)) { if (RXSDebug.isDebug()) Timber.tag(TAG).d("Process is no longer alive, skipping kill."); return true; } Matcher matcher = PID_... |
### Question:
RxProcess { public synchronized Completable close() { if (RXSDebug.isDebug()) Timber.tag(TAG).v("close()"); if (session == null) return Completable.complete(); else return session.flatMapCompletable(s -> s.destroy().andThen(s.waitFor().ignoreElement())); } RxProcess(ProcessFactory processFactory, ProcessK... |
### Question:
ProcessHelper { @SuppressLint("NewApi") public static boolean isAlive(Process process) { if (ApiWrap.hasOreo()) { return process.isAlive(); } else { try { process.exitValue(); return false; } catch (IllegalThreadStateException e) { return true; } } } @SuppressLint("NewApi") static boolean isAlive(Process... |
### Question:
UserKiller implements ProcessKiller { @SuppressLint("NewApi") @Override public boolean kill(Process process) { if (RXSDebug.isDebug()) Timber.tag(TAG).d("kill(%s)", process); if (!ProcessHelper.isAlive(process)) { if (RXSDebug.isDebug()) Timber.tag(TAG).d("Process is no longer alive, skipping kill."); ret... |
### Question:
DefaultProcessFactory implements ProcessFactory { @Override public Process start(String... commands) throws IOException { return new ProcessBuilder(commands).start(); } @Override Process start(String... commands); }### Answer:
@Test public void testStart() throws IOException { DefaultProcessFactory pf =... |
### Question:
Root { @Override public int hashCode() { return state.hashCode(); } Root(State state); State getState(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }### Answer:
@Test public void testEqualsHash() { Root root1 = new Root(Root.State.ROOTED); Root root2 = new ... |
### Question:
MordernWar implements War { public MordernWar(Enemy enemy) { this.enemy = enemy; } MordernWar(Enemy enemy); @Override Enemy getEnemy(); @Override void startWar(); @Override void combatting(); @Override void stopWar(); }### Answer:
@Test public void testMordernWar() { MordernWar war = spy(new MordernWar(m... |
### Question:
AncientWar implements War { public AncientWar(Enemy enemy) { this.enemy = enemy; } AncientWar(Enemy enemy); @Override Enemy getEnemy(); @Override void startWar(); @Override void combatting(); @Override void stopWar(); }### Answer:
@Test public void testAncientWar() { final AncientWar war = spy(new Ancien... |
### Question:
Writer { public CharacterComposite sentenceByChinese() { List<ChineseWord> words = new ArrayList<>(); words.add(new ChineseWord(Arrays.asList(new Character('我')))); words.add(new ChineseWord(Arrays.asList(new Character('是')))); words.add(new ChineseWord(Arrays.asList(new Character('来'), new Character('自')... |
### Question:
Writer { public CharacterComposite sentenceByEnglish() { List<EnglishWord> words = new ArrayList<>(); words.add(new EnglishWord(Arrays.asList(new Character('I')))); words.add(new EnglishWord(Arrays.asList(new Character('a'), new Character('m')))); words.add(new EnglishWord(Arrays.asList(new Character('a')... |
### Question:
Prototype implements Cloneable { @Override protected abstract Prototype clone() throws CloneNotSupportedException; }### Answer:
@Test public void testPrototype() throws Exception { assertEquals(this.prototype.toString(), this.expectedString); final Object clone = this.prototype.clone(); assertNotNull(c... |
### Question:
BenchJdbcAvroJob { public static void main(String[] cmdLineArgs) { try { create(cmdLineArgs).run(); } catch (Exception e) { ExceptionHandling.handleException(e); } } BenchJdbcAvroJob(final PipelineOptions pipelineOptions); static BenchJdbcAvroJob create(final String[] cmdLineArgs); void run(); static void... |
### Question:
JdbcAvroJob { public static JdbcAvroJob create(final PipelineOptions pipelineOptions, final String output) throws IOException, ClassNotFoundException { pipelineOptions.as(DirectOptions.class).setBlockOnRun(false); return new JdbcAvroJob( pipelineOptions, Pipeline.create(pipelineOptions), JdbcExportArgsFac... |
### Question:
PsqlAvroJob { public static PsqlAvroJob create(final String[] cmdLineArgs) throws IOException, ClassNotFoundException { JdbcAvroJob job = JdbcAvroJob.create(cmdLineArgs); PsqlReplicationCheck.validateOptions(job.getJdbcExportArgs()); final PsqlReplicationCheck psqlReplicationCheck = PsqlReplicationCheck.c... |
### Question:
PasswordReader { Optional<String> readPassword(final DBeamPipelineOptions options) throws IOException { FileSystems.setDefaultPipelineOptions(options); if (options.getPasswordFileKmsEncrypted() != null) { LOGGER.info("Decrypting password using KMS..."); return Optional.of( kmsDecrypter .decrypt(BeamHelper... |
### Question:
JobNameConfiguration { public static void configureJobName(final PipelineOptions options, final String... parts) { try { options.as(ApplicationNameOptions.class).setAppName("JdbcAvroJob"); } catch (Exception e) { LOGGER.warn("Unable to configure ApplicationName", e); } if (options.getJobName() == null || ... |
### Question:
QueryBuilderArgs implements Serializable { public static QueryBuilderArgs create(final String tableName) { checkArgument(tableName != null, "TableName cannot be null"); checkArgument(checkTableName(tableName), "'table' must follow [a-zA-Z_][a-zA-Z0-9_]*"); return createBuilder().setBaseSqlQuery(QueryBuild... |
### Question:
QueryBuilderArgs implements Serializable { public abstract Optional<Instant> partition(); abstract Optional<Long> limit(); abstract Optional<String> partitionColumn(); abstract Optional<Instant> partition(); abstract TemporalAmount partitionPeriod(); abstract Optional<String> splitColumn(); abstract Opti... |
### Question:
ParallelQueryBuilder implements Serializable { protected static List<String> queriesForBounds( long min, long max, int parallelism, String splitColumn, QueryBuilder queryBuilder) { List<QueryRange> ranges = generateRanges(min, max, parallelism); return ranges.stream() .map( x -> queryBuilder .withParallel... |
### Question:
PathUtils { public static HashCode sha256(final Path file) throws IOException { return MoreFiles.asByteSource(file).hash(Hashing.sha256()); } private PathUtils(); static HashCode sha256(final Path file); static void syncRecursive(final Path source, final Path target); static void removeRecursive(final Pa... |
### Question:
PathUtils { static Path equivalentSubpath(final Path a, final Path b, final Path path) { return b.resolve(a.relativize(path)); } private PathUtils(); static HashCode sha256(final Path file); static void syncRecursive(final Path source, final Path target); static void removeRecursive(final Path path); }#... |
### Question:
PathUtils { public static void removeRecursive(final Path path) throws IOException { Files.walkFileTree( path, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException { Files.deleteIfExists(file); return FileVisitResul... |
### Question:
ConfigurationServlet extends PassThroughAuthenticationServlet { @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doWithAuthentication(request, response, this::updateConfiguration); } @SuppressWarnings("unused") // production c... |
### Question:
ExporterConfig { boolean getMetricsNameSnakeCase() { return metricsNameSnakeCase; } private ExporterConfig(Map<String, Object> yaml); static ExporterConfig createEmptyConfig(); static ExporterConfig loadConfig(InputStream inputStream); Map<String, Object> scrapeMetrics(MBeanSelector selector, JsonObject ... |
### Question:
ExporterConfig { public Integer getRestPort() { return restPort; } private ExporterConfig(Map<String, Object> yaml); static ExporterConfig createEmptyConfig(); static ExporterConfig loadConfig(InputStream inputStream); Map<String, Object> scrapeMetrics(MBeanSelector selector, JsonObject response); MBeanS... |
### Question:
ExporterConfig { boolean useDomainQualifier() { return useDomainQualifier && (domainName == null); } private ExporterConfig(Map<String, Object> yaml); static ExporterConfig createEmptyConfig(); static ExporterConfig loadConfig(InputStream inputStream); Map<String, Object> scrapeMetrics(MBeanSelector sele... |
### Question:
ExporterConfig { public MBeanSelector[] getQueries() { if (queries == null) return NO_QUERIES; return queries; } private ExporterConfig(Map<String, Object> yaml); static ExporterConfig createEmptyConfig(); static ExporterConfig loadConfig(InputStream inputStream); Map<String, Object> scrapeMetrics(MBeanS... |
### Question:
ExporterConfig { @Override public String toString() { StringBuilder sb = new StringBuilder(); if (querySyncConfiguration != null) sb.append(querySyncConfiguration); if (metricsNameSnakeCase) sb.append("metricsNameSnakeCase: true\n"); if (useDomainQualifier) sb.append(DOMAIN_QUALIFIER + ": true\n"); if (re... |
### Question:
SnakeCaseUtil { static String convert(String s) { return SNAKE_CASE_PATTERN.matcher(s).replaceAll("$1_$2").toLowerCase(); } static boolean isCompliant(String s); }### Answer:
@Test public void convertToSnakeCase() throws Exception { assertThat(SnakeCaseUtil.convert("simple"), equalTo("simple")); assertT... |
### Question:
SnakeCaseUtil { public static boolean isCompliant(String s) { return s.equals(convert(s)); } static boolean isCompliant(String s); }### Answer:
@Test public void verifiesSnakeCase() throws Exception { assertThat(SnakeCaseUtil.isCompliant("simple"), is(true)); assertThat(SnakeCaseUtil.isCompliant("an_exa... |
### Question:
MapUtils { @SuppressWarnings("unchecked") static String[] getStringArray(Map<String, Object> map, String key) { Object value = map.get(key); if (value instanceof List) return toStringArray((List<Object>) value); else if (!value.getClass().isArray()) return new String[]{value.toString()}; else if (value.ge... |
### Question:
MBeanSelector { public static MBeanSelector create(Map<String, Object> map) { return new MBeanSelector(map); } private MBeanSelector(Map<String, Object> map); private MBeanSelector(MBeanSelector first, MBeanSelector second); static MBeanSelector create(Map<String, Object> map); String getPrintableReques... |
### Question:
MBeanSelector { MBeanSelector merge(MBeanSelector selector) { return new MBeanSelector(this, selector); } private MBeanSelector(Map<String, Object> map); private MBeanSelector(MBeanSelector first, MBeanSelector second); static MBeanSelector create(Map<String, Object> map); String getPrintableRequest(); ... |
### Question:
MBeanSelector { boolean mayMergeWith(MBeanSelector other) { if (!Objects.equals(keyName, other.keyName)) return false; if (!Objects.equals(key, other.key)) return false; if (!Objects.equals(type, other.type)) return false; if (!Objects.equals(prefix, other.prefix)) return false; for (String key : nestedSe... |
### Question:
MBeanSelector { public String getUrl(Protocol protocol, String host, int port) { return protocol.format(queryType.getUrlPattern(), host, port); } private MBeanSelector(Map<String, Object> map); private MBeanSelector(MBeanSelector first, MBeanSelector second); static MBeanSelector create(Map<String, Obje... |
### Question:
MBeanSelector { String[] getValues() { return values == null ? NO_VALUES : values; } private MBeanSelector(Map<String, Object> map); private MBeanSelector(MBeanSelector first, MBeanSelector second); static MBeanSelector create(Map<String, Object> map); String getPrintableRequest(); String getRequest(); ... |
### Question:
MainServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { LiveConfiguration.updateConfiguration(); LiveConfiguration.setServer(req); resp.getOutputStream().println(ServletConstants.PAGE_HEADER); displayMetricsLink(req, resp.getO... |
### Question:
WebClientFactoryImpl implements WebClientFactory { static Constructor<? extends WebClient> getClientConstructor() { for (String className : CLIENT_CLASS_NAMES) { try { return getClientConstructor(className); } catch (NoClassDefFoundError | NoSuchMethodException ignored) { } } throw new IllegalStateExcepti... |
### Question:
BuildHelperMojo extends AbstractMojo { public void execute() throws MojoExecutionException { Path source = toPath(sourceFile); Path target = toPath(targetFile); try { getLog().info("Copying " + source + " to " + target); executor.copyFile(source, target); } catch (IOException e) { throw new MojoExecutionE... |
### Question:
ErrorLog { void log(Throwable throwable) { errors.append(toLogMessage(throwable)); for (Throwable cause = throwable.getCause(); cause != null; cause = cause.getCause()) errors.append(System.lineSeparator()).append(" ").append(toLogMessage(cause)); } }### Answer:
@Test public void afterExceptionReported... |
### Question:
ConfigurationUpdaterImpl implements ConfigurationUpdater { @Override public long getLatestConfigurationTimestamp() { getLatestConfiguration(); return latest == null ? 0 : latest.getTimestamp(); } ConfigurationUpdaterImpl(QuerySyncConfiguration syncConfiguration, ErrorLog errorLog); ConfigurationUpdaterI... |
### Question:
ConfigurationUpdaterImpl implements ConfigurationUpdater { @Override public ConfigurationUpdate getUpdate() { getLatestConfiguration(); return latest; } ConfigurationUpdaterImpl(QuerySyncConfiguration syncConfiguration, ErrorLog errorLog); ConfigurationUpdaterImpl(Clock clock, WebClientFactory factory);... |
### Question:
ConfigurationUpdaterImpl implements ConfigurationUpdater { @Override public void shareConfiguration(String configuration) { try { WebClient client = factory.createClient().withUrl(repeaterUrl); client.doPutRequest(new Gson().toJson(createUpdate(configuration))); } catch (IOException | WebClientException e... |
### Question:
MultipartContentParser implements ParserActions { String getBoundary() { return boundary; } MultipartContentParser(String contentType); ParserState getState(); @Override boolean isStart(String line); @Override boolean isEnd(String line); @Override ParserState closeItem(ParserState state); @Override Parser... |
### Question:
MultipartContentParser implements ParserActions { public ParserState getState() { return state; } MultipartContentParser(String contentType); ParserState getState(); @Override boolean isStart(String line); @Override boolean isEnd(String line); @Override ParserState closeItem(ParserState state); @Override ... |
### Question:
MultipartContentParser implements ParserActions { MultipartItem getCurrentItem() { if (currentItem == null) currentItem = new MultipartItemImpl(); return currentItem; } MultipartContentParser(String contentType); ParserState getState(); @Override boolean isStart(String line); @Override boolean isEnd(Strin... |
### Question:
MultipartContentParser implements ParserActions { static List<MultipartItem> parse(HttpServletRequest request) throws ServletException { try { final MultipartContentParser parser = new MultipartContentParser(request.getContentType()); new BufferedReader(new InputStreamReader(request.getInputStream())).lin... |
### Question:
UrlBuilder { public String createUrl(String urlPattern) { return protocol.format(urlPattern, host, selectPort()); } UrlBuilder(HttpServletRequest request, Integer restPort); static void clearHistory(); String createUrl(String urlPattern); void reportSuccess(); void reportFailure(WebClientException connect... |
### Question:
MessagesServlet extends HttpServlet { static List<String> getMessages() { return new ArrayList<>(messages); } }### Answer:
@Test public void afterMaximumExchangesAdded_retrieveAllExchanges() { IntStream.rangeClosed(1, MAX_EXCHANGES).forEach(this::addTestExchange); assertThat(MessagesServlet.getMessages... |
### Question:
MessagesServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { try(ServletOutputStream out = resp.getOutputStream()) { for (String message : messages) out.println(message); } } }### Answer:
@Test public void whenServletInvoked... |
### Question:
LiveConfiguration { static boolean hasQueries() { return getConfig() != null && getConfig().getQueries().length > 0; } }### Answer:
@Test public void whenInitNotCalled_haveNoQueries() { assertThat(LiveConfiguration.hasQueries(), is(false)); } |
### Question:
LiveConfiguration { static void init(ServletConfig servletConfig) { if (timestamp != null) return; InputStream configurationFile = getConfigurationFile(servletConfig); initialize(Optional.ofNullable(configurationFile) .map(ExporterConfig::loadConfig) .orElse(ExporterConfig.createEmptyConfig())); } }###... |
### Question:
LogServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { String errors = LiveConfiguration.getErrors(); if (errors == null || errors.trim().length() == 0) resp.getOutputStream().println("No errors reported."); else resp.getOutpu... |
### Question:
MetricsStream extends PrintStream { void printMetric(String name, Object value) { print(name + " " + value + '\n'); scrapeCount++; } MetricsStream(HttpServletRequest request, OutputStream outputStream); MetricsStream(HttpServletRequest request, OutputStream outputStream, PerformanceProbe performanceProb... |
### Question:
Header { public String getName() { return name; } Header(String headerLine); String getValue(); String getValue(String key); String getName(); static final String QUOTE; }### Answer:
@Test public void fetchHeaderName() { Header header = new Header("Content-type: text/plain"); assertThat(header.getName(), ... |
### Question:
Header { public String getValue() { return value; } Header(String headerLine); String getValue(); String getValue(String key); String getName(); static final String QUOTE; }### Answer:
@Test public void fetchMainValue() { Header header = new Header("Content-type: text/plain"); assertThat(header.getValue()... |
### Question:
MetricsScraper { Map<String, Object> scrape(MBeanSelector selector, JsonObject response) { metrics = new HashMap<>(); scrapeItem(response, selector, globalQualifiers); return metrics; } MetricsScraper(String globalQualifiers); }### Answer:
@Test public void whenResponseLacksServerRuntimes_generateEmptyM... |
### Question:
ExporterConfig { public static ExporterConfig loadConfig(InputStream inputStream) { try { return loadConfig(asMap(new Yaml().load(inputStream))); } catch (ScannerException e) { throw new YamlParserException(e); } } private ExporterConfig(Map<String, Object> yaml); static ExporterConfig createEmptyConfig(... |
### Question:
ExporterConfig { public MBeanSelector[] getEffectiveQueries() { if (queries == null) return NO_QUERIES; return withPossibleDomainNameQuery(Arrays.stream(queries)).toArray(MBeanSelector[]::new); } private ExporterConfig(Map<String, Object> yaml); static ExporterConfig createEmptyConfig(); static ExporterC... |
### Question:
ExporterConfig { public QuerySyncConfiguration getQuerySyncConfiguration() { return querySyncConfiguration; } private ExporterConfig(Map<String, Object> yaml); static ExporterConfig createEmptyConfig(); static ExporterConfig loadConfig(InputStream inputStream); Map<String, Object> scrapeMetrics(MBeanSele... |
### Question:
AuthUserDetailsService implements UserDetailsService { @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { User user = repository.findOne(username); if (user == null) { throw new UsernameNotFoundException(username); } log.debug(" User from username ", user.t... |
### Question:
UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService { @DS("master") @Override public void addUser(User user) { baseMapper.insert(user); } @DS("master") @Override void addUser(User user); }### Answer:
@Test public void addUser() { User userMaster = User.builder().name("主库添加").age... |
### Question:
RedisUtil { public PageResult<String> findKeysForPage(String patternKey, int currentPage, int pageSize) { ScanOptions options = ScanOptions.scanOptions() .match(patternKey) .build(); RedisConnectionFactory factory = stringRedisTemplate.getConnectionFactory(); RedisConnection rc = factory.getConnection(); ... |
### Question:
SelectIndexDataActivity extends BaseActivity { public static int partition(int[] a, int p, int r) { int x = a[r]; int i = p - 1; for (int j = p; j < r; j++) { if (a[j] <= x) { i = i + 1; swap(a, i, j); System.out.println("交换=" + "i=" + i + Arrays.toString(a)); }else{ System.out.println("未交换=" + "i=" + i +... |
### Question:
SelectIndexDataActivity extends BaseActivity { public static int randomizedSelect(int[] a, int p, int r, int i) { if (p == r) { return a[p]; } int q = randomizedPartition(a, p, r); int k = q - p + 1; if (i == k) { return a[q]; } else if (i < k) { return randomizedSelect(a, p, q - 1, i); } else { return ra... |
### Question:
PermissiveURI { public static URI create(String s) { return URI.create(s.replace(" ", "%20")); } static URI create(String s); }### Answer:
@Test public void simple() throws Exception { URI i = PermissiveURI.create("file:/funk"); assertEquals("/funk", Paths.get(i).toString()); }
@Test public void undone(... |
### Question:
AddAnimalPresenter extends BasePresenter<AddAnimalContract.View> implements AddAnimalContract.Presenter<AddAnimalContract.View> { @Override public void addNewDog(DogFirebase dogFirebase) { firebaseRepository.addNew(dogFirebase); } AddAnimalPresenter(Repository.Firebase<DogFirebase> repository); @Override ... |
### Question:
DeleteMessage extends UpdatableChatRequest { public static DeleteMessageBuilder forMessage(Message<?> message) { Objects.requireNonNull(message, "message cannot be null"); return builder() .chatId(message.getChat().getChatId()) .messageId(message.getMessageId()); } @Builder DeleteMessage(Consumer<Telegra... |
### Question:
EditMessageMedia extends SendableInputFileInlineRequest<Message> { public static EditMessageMediaBuilder forMessage(AudioMessage message) { Objects.requireNonNull(message, "audio message cannot be null"); return builder() .chatId(message.getChat().getChatId()) .messageId(message.getMessageId()); } @Builde... |
### Question:
EditMessageMedia extends SendableInputFileInlineRequest<Message> { public static EditMessageMediaBuilder forInlineMessage(String inlineMessageId) { Objects.requireNonNull(inlineMessageId, "inline message ID cannot be null"); return builder().inlineMessageId(inlineMessageId); } @Builder protected EditMess... |
### Question:
EditMessageReplyMarkup extends EditMessageRequest<Message> { public static EditMessageReplyMarkupBuilder forMessage(Message<?> message) { Objects.requireNonNull(message, "message cannot be null"); return builder() .chatId(message.getChat().getChatId()) .messageId(message.getMessageId()); } @Builder EditM... |
### Question:
EditMessageReplyMarkup extends EditMessageRequest<Message> { public static EditMessageReplyMarkupBuilder forInlineMessage(String inlineMessageId) { Objects.requireNonNull(inlineMessageId, "inline message ID cannot be null"); return builder().inlineMessageId(inlineMessageId); } @Builder EditMessageReplyMa... |
### Question:
EditTextMessage extends EditMessageRequest<TextMessage> { public static EditTextMessageBuilder forMessage(TextMessage message) { Objects.requireNonNull(message, "text message cannot be null"); return builder() .chatId(message.getChat().getChatId()) .messageId(message.getMessageId()); } @Builder EditTextM... |
### Question:
EditTextMessage extends EditMessageRequest<TextMessage> { public static EditTextMessageBuilder forInlineMessage(String inlineMessageId) { Objects.requireNonNull(inlineMessageId, "inline message ID cannot be null"); return builder().inlineMessageId(inlineMessageId); } @Builder EditTextMessage(Consumer<Tex... |
### Question:
EditMessageLiveLocation extends SendableInlineRequest<Message> { public static EditMessageLiveLocationBuilder forMessage(LocationMessage message) { Objects.requireNonNull(message, "message cannot be null"); return builder() .chatId(message.getChat().getChatId()) .messageId(message.getMessageId()); } @Buil... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.