method2testcases
stringlengths
118
3.08k
### Question: PixabayImage { public int getPreviewHeight() { return previewHeight; } PixabayImage(int previewHeight, int likes, int favorites, String tags, int webformatHeight, long views, int webformatWidth, int previewWidth, int comments, long downloads, String pageURL,...
### Question: PixabayImage { public String getPageURL() { return pageURL; } PixabayImage(int previewHeight, int likes, int favorites, String tags, int webformatHeight, long views, int webformatWidth, int previewWidth, int comments, long downloads, String pageURL, String p...
### Question: PixabayImage { public String getPreviewURL() { return previewURL; } PixabayImage(int previewHeight, int likes, int favorites, String tags, int webformatHeight, long views, int webformatWidth, int previewWidth, int comments, long downloads, String pageURL, St...
### Question: PixabayImage { public String getWebformatURL() { return webformatURL; } PixabayImage(int previewHeight, int likes, int favorites, String tags, int webformatHeight, long views, int webformatWidth, int previewWidth, int comments, long downloads, String pageURL...
### Question: PixabayImage { public int getImageWidth() { return imageWidth; } PixabayImage(int previewHeight, int likes, int favorites, String tags, int webformatHeight, long views, int webformatWidth, int previewWidth, int comments, long downloads, String pageURL, Strin...
### Question: PixabayImage { public long getUserId() { return userId; } PixabayImage(int previewHeight, int likes, int favorites, String tags, int webformatHeight, long views, int webformatWidth, int previewWidth, int comments, long downloads, String pageURL, String previ...
### Question: PixabayImage { public String getUser() { return "By: " + user; } PixabayImage(int previewHeight, int likes, int favorites, String tags, int webformatHeight, long views, int webformatWidth, int previewWidth, int comments, long downloads, String pageURL, Strin...
### Question: PixabayImage { public PixabayImageType getType() { return type; } PixabayImage(int previewHeight, int likes, int favorites, String tags, int webformatHeight, long views, int webformatWidth, int previewWidth, int comments, long downloads, String pageURL, Stri...
### Question: PixabayImage { public long getId() { return id; } PixabayImage(int previewHeight, int likes, int favorites, String tags, int webformatHeight, long views, int webformatWidth, int previewWidth, int comments, long downloads, String pageURL, String previewURL, ...
### Question: PixabayImage { public String getUserImageURL() { return userImageURL; } PixabayImage(int previewHeight, int likes, int favorites, String tags, int webformatHeight, long views, int webformatWidth, int previewWidth, int comments, long downloads, String pageURL...
### Question: PixabayImage { public int getImageHeight() { return imageHeight; } PixabayImage(int previewHeight, int likes, int favorites, String tags, int webformatHeight, long views, int webformatWidth, int previewWidth, int comments, long downloads, String pageURL, Str...
### Question: PixabayImage { public String getLikes() { return String.valueOf(likes); } PixabayImage(int previewHeight, int likes, int favorites, String tags, int webformatHeight, long views, int webformatWidth, int previewWidth, int comments, long downloads, String pageU...
### Question: PixabayImage { public String getFavorites() { return String.valueOf(favorites); } PixabayImage(int previewHeight, int likes, int favorites, String tags, int webformatHeight, long views, int webformatWidth, int previewWidth, int comments, long downloads, Stri...
### Question: PixabayImage { public String getTags() { if (tags == null) return ""; if (tags.contains(", ")) { String[] splitTags = tags.toUpperCase().split(", "); return TextUtils.join(" - ", splitTags); } else return tags; } PixabayImage(int previewHeight, int likes, int favorites, String tags, ...
### Question: PixabayImage { public int getWebformatHeight() { return webformatHeight; } PixabayImage(int previewHeight, int likes, int favorites, String tags, int webformatHeight, long views, int webformatWidth, int previewWidth, int comments, long downloads, String page...
### Question: PixabayImage { public long getViews() { return views; } PixabayImage(int previewHeight, int likes, int favorites, String tags, int webformatHeight, long views, int webformatWidth, int previewWidth, int comments, long downloads, String pageURL, String preview...
### Question: PixabayImage { public int getWebformatWidth() { return webformatWidth; } PixabayImage(int previewHeight, int likes, int favorites, String tags, int webformatHeight, long views, int webformatWidth, int previewWidth, int comments, long downloads, String pageUR...
### Question: PixabayImage { public int getPreviewWidth() { return previewWidth; } PixabayImage(int previewHeight, int likes, int favorites, String tags, int webformatHeight, long views, int webformatWidth, int previewWidth, int comments, long downloads, String pageURL, S...
### Question: PixabayImage { public String getComments() { return String.valueOf(comments); } PixabayImage(int previewHeight, int likes, int favorites, String tags, int webformatHeight, long views, int webformatWidth, int previewWidth, int comments, long downloads, String...
### Question: PixabayImage { public long getDownloads() { return downloads; } PixabayImage(int previewHeight, int likes, int favorites, String tags, int webformatHeight, long views, int webformatWidth, int previewWidth, int comments, long downloads, String pageURL, String...
### Question: ClientSpanNameProvider { public static Function<HttpRequest, String> PREFIXED_REQUEST_METHOD_NAME(final String prefix) { return (request) -> replaceIfNull(prefix, "") + replaceIfNull(request.getRequestLine().getMethod(), "unknown"); } static Function<HttpRequest, String> PREFIXED_REQUEST_METHOD_NAME(fina...
### Question: RxReceiver { @NonNull public static Observable<Intent> receives(@NonNull final Context context, @NonNull final IntentFilter intentFilter) { return Observable.create(new ObservableOnSubscribe<Intent>() { @Override public void subscribe(final ObservableEmitter<Intent> emitter) { final BroadcastReceiver rece...
### Question: RxReceiver { @NonNull @CheckResult public static Observable<Intent> receives(@NonNull final Context context, @NonNull final IntentFilter intentFilter) { return Observable.create(new Action1<Emitter<Intent>>() { @Override public void call(final Emitter<Intent> emitter) { final BroadcastReceiver receiver = ...
### Question: RxReceiverLocal { @NonNull public static Observable<Intent> receives(@NonNull final Context context, @NonNull final IntentFilter intentFilter) { return Observable.create(new ObservableOnSubscribe<Intent>() { @Override public void subscribe(final ObservableEmitter<Intent> emitter) { final BroadcastReceiver...
### Question: FlaxModel { protected void notifyModelChanged() { modelSubject.onNext((M)this); } FlaxModel(); }### Answer: @Test public void testNotifyModelChanged() throws Exception { TestObserver testSubscriber = flaxModel.getObservable().test(); flaxModel.notifyModelChanged(); flaxModel.notifyModelChanged(); testSu...
### Question: FlaxStore { static<M extends FlaxModel> M getModel(Class modelClass) { return getModel(modelClass, 0); } private FlaxStore(); }### Answer: @Test public void testStoreReturnsSameValueForSameKeys() throws Exception { Foo fooOne = FlaxStore.getModel(Foo.class, 0); Foo fooTwo = FlaxStore.getModel(Foo.class...
### Question: PCA9685Servo extends PCA9685 { public int map(int x, int inMin, int inMax, int outMin, int outMax) { return (x - inMin) * (outMax - outMin) / (inMax - inMin) + outMin; } PCA9685Servo(byte address, @NonNull PeripheralManager manager); void setServoMinMaxPwm(int minAngle, int maxAngle, int minPwm, int maxPw...
### Question: Order { public double getTotal() { double total = 0; for (Product product : products) { total += product.getPrice(); } return total; } Order(Product ... products); double getTotal(); }### Answer: @Test public void should_sum_all_prices() { Order order = new Order(new Product(30), new Product(40.0)); asse...
### Question: PgConfigurationProperties implements ApplicationListener<ApplicationReadyEvent> { public int getPageSizeForIds() { return pageSize * idOnlyFactor; } int getPageSizeForIds(); int getQueueSizeForIds(); int getFetchSizeForIds(); int getFetchSize(); @Override void onApplicationEvent(ApplicationReadyEvent eve...
### Question: GrpcFactStore implements FactStore, SmartInitializingSingleton { @Override public long currentTime() { MSG_Empty empty = converter.empty(); MSG_CurrentDatabaseTime resp; try { resp = blockingStub.currentTime(empty); } catch (StatusRuntimeException e) { throw wrapRetryable(e); } return converter.fromProto(...
### Question: FactCastJson { @SneakyThrows public static <T> T copy(@NonNull T toCopy) { Class<?> c = toCopy.getClass(); return reader.forType(c).readValue(writer.forType(c).writeValueAsString(toCopy)); } @SneakyThrows static T copy(@NonNull T toCopy); @SneakyThrows static String writeValueAsString(@NonNull T value); ...
### Question: FactCastJson { @SneakyThrows public static <T> T readValue(@NonNull Class<T> class1, String json) { return reader.forType(class1).readValue(json); } @SneakyThrows static T copy(@NonNull T toCopy); @SneakyThrows static String writeValueAsString(@NonNull T value); @SneakyThrows static T readValue(@NonNull ...
### Question: FactCastJson { @SneakyThrows public static <T> String writeValueAsString(@NonNull T value) { return writer.writeValueAsString(value); } @SneakyThrows static T copy(@NonNull T toCopy); @SneakyThrows static String writeValueAsString(@NonNull T value); @SneakyThrows static T readValue(@NonNull Class<T> clas...
### Question: FactCastJson { public static ObjectNode newObjectNode() { return objectMapper.getNodeFactory().objectNode(); } @SneakyThrows static T copy(@NonNull T toCopy); @SneakyThrows static String writeValueAsString(@NonNull T value); @SneakyThrows static T readValue(@NonNull Class<T> class1, String json); @Sneaky...
### Question: FactCastJson { public static ObjectNode toObjectNode(String json) { try { return (ObjectNode) objectMapper.readTree(json); } catch (IOException e) { throw new RuntimeException(e); } } @SneakyThrows static T copy(@NonNull T toCopy); @SneakyThrows static String writeValueAsString(@NonNull T value); @Sneaky...
### Question: PgFactExtractor implements RowMapper<Fact> { @Override @NonNull public Fact mapRow(@NonNull ResultSet rs, int rowNum) throws SQLException { serial.set(rs.getLong(PgConstants.COLUMN_SER)); return PgFact.from(rs); } @Override @NonNull Fact mapRow(@NonNull ResultSet rs, int rowNum); }### Answer: @Test void...
### Question: FactCastJson { @SneakyThrows @Generated public static String writeValueAsPrettyString(Object o) { return objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(o); } @SneakyThrows static T copy(@NonNull T toCopy); @SneakyThrows static String writeValueAsString(@NonNull T value); @SneakyThrows s...
### Question: JavaScriptEngineSupplier implements Supplier<ScriptEngine> { @Override public ScriptEngine get() { ScriptEngine engine = getEngineByName("nashorn", "javascript", "js"); if (engine == null) throw new IllegalStateException("Cannot find any engine to run javascript code."); return engine; } JavaScriptEngineS...
### Question: FactSpec { public static FactSpec ns(String ns) { return new FactSpec(ns); } FactSpec(@NonNull @JsonProperty("ns") String ns); FactSpec meta(@NonNull String k, @NonNull String v); static FactSpec ns(String ns); FilterScript filterScript(); FactSpec filterScript(FilterScript script); @Deprecated FactSpec j...
### Question: FactSpec { public FilterScript filterScript() { if (filterScript != null) return filterScript; else if (jsFilterScript != null) return new FilterScript("js", jsFilterScript); else return null; } FactSpec(@NonNull @JsonProperty("ns") String ns); FactSpec meta(@NonNull String k, @NonNull String v); static F...
### Question: FactSpecMatcher implements Predicate<Fact> { protected boolean metaMatch(Fact t) { if ((meta.isEmpty())) { return true; } return meta.entrySet().stream().allMatch(e -> e.getValue().equals(t.meta(e.getKey()))); } FactSpecMatcher(@NonNull FactSpec spec); @Override boolean test(Fact t); static Predicate<Fact...
### Question: PgIdFactExtractor implements RowMapper<Fact> { @Override @NonNull public Fact mapRow(@NonNull ResultSet rs, int rowNum) throws SQLException { serial.set(rs.getLong(PgConstants.COLUMN_SER)); return new IdOnlyFact(UUID.fromString(rs.getString(PgConstants.ALIAS_ID))); } @Override @NonNull Fact mapRow(@NonNu...
### Question: FactSpecMatcher implements Predicate<Fact> { protected boolean nsMatch(Fact t) { return ns.equals(t.ns()); } FactSpecMatcher(@NonNull FactSpec spec); @Override boolean test(Fact t); static Predicate<Fact> matchesAnyOf(@NonNull List<FactSpec> spec); static Predicate<Fact> matches(@NonNull FactSpec spec); ...
### Question: FactSpecMatcher implements Predicate<Fact> { protected boolean typeMatch(Fact t) { if (type == null) { return true; } String otherType = t.type(); return type.equals(otherType); } FactSpecMatcher(@NonNull FactSpec spec); @Override boolean test(Fact t); static Predicate<Fact> matchesAnyOf(@NonNull List<Fac...
### Question: FactSpecMatcher implements Predicate<Fact> { protected boolean aggIdMatch(Fact t) { if (aggId == null) { return true; } return t.aggIds().contains(aggId); } FactSpecMatcher(@NonNull FactSpec spec); @Override boolean test(Fact t); static Predicate<Fact> matchesAnyOf(@NonNull List<FactSpec> spec); static Pr...
### Question: FactSpecMatcher implements Predicate<Fact> { @SneakyThrows @Generated protected boolean scriptMatch(Fact t) { if (script == null) { return true; } return (Boolean) scriptEngine.eval("test(" + t.jsonHeader() + "," + t.jsonPayload() + ")"); } FactSpecMatcher(@NonNull FactSpec spec); @Override boolean test(F...
### Question: FactSpecMatcher implements Predicate<Fact> { public static Predicate<Fact> matchesAnyOf(@NonNull List<FactSpec> spec) { List<FactSpecMatcher> matchers = spec.stream() .map(FactSpecMatcher::new) .collect(Collectors.toList()); return f -> matchers.stream().anyMatch(p -> p.test(f)); } FactSpecMatcher(@NonNul...
### Question: FactSpecMatcher implements Predicate<Fact> { public static Predicate<Fact> matches(@NonNull FactSpec spec) { return new FactSpecMatcher(spec); } FactSpecMatcher(@NonNull FactSpec spec); @Override boolean test(Fact t); static Predicate<Fact> matchesAnyOf(@NonNull List<FactSpec> spec); static Predicate<Fact...
### Question: IdOnlyFact implements Fact { @Override public String ns() { throw new UnsupportedOperationException(); } @Override String ns(); @Override String type(); @Override Set<UUID> aggIds(); @Override String jsonHeader(); @Override String jsonPayload(); @Override String meta(String key); }### Answer: @Test void...
### Question: IdOnlyFact implements Fact { @Override public String type() { throw new UnsupportedOperationException(); } @Override String ns(); @Override String type(); @Override Set<UUID> aggIds(); @Override String jsonHeader(); @Override String jsonPayload(); @Override String meta(String key); }### Answer: @Test vo...
### Question: IdOnlyFact implements Fact { @Override public Set<UUID> aggIds() { throw new UnsupportedOperationException(); } @Override String ns(); @Override String type(); @Override Set<UUID> aggIds(); @Override String jsonHeader(); @Override String jsonPayload(); @Override String meta(String key); }### Answer: @Te...
### Question: IdOnlyFact implements Fact { @Override public String jsonHeader() { throw new UnsupportedOperationException(); } @Override String ns(); @Override String type(); @Override Set<UUID> aggIds(); @Override String jsonHeader(); @Override String jsonPayload(); @Override String meta(String key); }### Answer: @T...
### Question: IdOnlyFact implements Fact { @Override public String jsonPayload() { throw new UnsupportedOperationException(); } @Override String ns(); @Override String type(); @Override Set<UUID> aggIds(); @Override String jsonHeader(); @Override String jsonPayload(); @Override String meta(String key); }### Answer: @...
### Question: IdOnlyFact implements Fact { @Override public String meta(String key) { throw new UnsupportedOperationException(); } @Override String ns(); @Override String type(); @Override Set<UUID> aggIds(); @Override String jsonHeader(); @Override String jsonPayload(); @Override String meta(String key); }### Answer...
### Question: DefaultFactCast implements FactCast { @Override @NonNull public Subscription subscribeEphemeral(@NonNull SubscriptionRequest req, @NonNull FactObserver observer) { return store.subscribe(SubscriptionRequestTO.forFacts(req), observer); } @Override @NonNull Subscription subscribeEphemeral(@NonNull Subscrip...
### Question: DefaultFactCast implements FactCast { @Override public void publish(@NonNull List<? extends Fact> factsToPublish) { FactValidation.validate(factsToPublish); store.publish(factsToPublish); } @Override @NonNull Subscription subscribeEphemeral(@NonNull SubscriptionRequest req, @NonNull FactObser...
### Question: PgFact implements Fact { @VisibleForTesting static Set<UUID> toUUIDArray(String aggIdArrayAsString) { Set<UUID> set = new LinkedHashSet<>(); if (aggIdArrayAsString != null && aggIdArrayAsString.trim().length() > 2) { UUID[] readValue = FactCastJson.readValue(UUID[].class, aggIdArrayAsString); if (readValu...
### Question: DefaultFactCast implements FactCast { @Override @NonNull public OptionalLong serialOf(@NonNull UUID id) { return store.serialOf(id); } @Override @NonNull Subscription subscribeEphemeral(@NonNull SubscriptionRequest req, @NonNull FactObserver observer); @Override void publish(@NonNull List<? e...
### Question: DefaultFactCast implements FactCast { @Override public Set<String> enumerateNamespaces() { return store.enumerateNamespaces(); } @Override @NonNull Subscription subscribeEphemeral(@NonNull SubscriptionRequest req, @NonNull FactObserver observer); @Override void publish(@NonNull List<? extends...
### Question: DefaultFactCast implements FactCast { @Override public Set<String> enumerateTypes(@NonNull String ns) { return store.enumerateTypes(ns); } @Override @NonNull Subscription subscribeEphemeral(@NonNull SubscriptionRequest req, @NonNull FactObserver observer); @Override void publish(@NonNull List...
### Question: DefaultFactCast implements FactCast { @Override public LockedOperationBuilder lock(@NonNull String ns) { if (ns.trim().isEmpty()) throw new IllegalArgumentException("Namespace must not be empty"); return new LockedOperationBuilder(this.store, ns); } @Override @NonNull Subscription subscribeEphemeral(@Non...
### Question: StateToken { public StateToken() { this(UUID.randomUUID()); } StateToken(); }### Answer: @Test public void testStateToken() throws Exception { assertThat(new StateToken().uuid()).isNotNull(); }
### Question: IntermediatePublishResult { public Optional<Runnable> andThen() { return Optional.ofNullable(andThen); } Optional<Runnable> andThen(); }### Answer: @Test public void testNullContracts() throws Exception { assertThrows(NullPointerException.class, () -> { new IntermediatePublishResult(null); }); assertThr...
### Question: LockedOperationBuilder { public OnBuilderStep on(@NonNull UUID aggId, UUID... otherAggIds) { LinkedList<UUID> ids = new LinkedList<>(); ids.add(aggId); ids.addAll(Arrays.asList(otherAggIds)); return new OnBuilderStep(ids); } OnBuilderStep on(@NonNull UUID aggId, UUID... otherAggIds); }### Answer: @Test ...
### Question: ExceptionAfterPublish extends IllegalStateException { public ExceptionAfterPublish(@NonNull List<Fact> publishedFacts, @NonNull Throwable e) { super("An exception has happened in the 'andThen' part of your publishing attempt. " + "This is a programming error, as the runnable in andThen is not supposed to ...
### Question: WithOptimisticLock { @NonNull public PublishingResult attempt(@NonNull Attempt operation) throws AttemptAbortedException, OptimisticRetriesExceededException, ExceptionAfterPublish { while (++count <= retry) { StateToken token = store.stateFor(ids, Optional.ofNullable(ns)); try { IntermediatePublishResult ...
### Question: SubscriptionImpl implements Subscription { @Override public void close() { if (!closed.getAndSet(true)) { SubscriptionCancelledException closedException = new SubscriptionCancelledException( "Client closed the subscription"); catchup.completeExceptionally(closedException); complete.completeExceptionally(c...
### Question: SubscriptionImpl implements Subscription { @Override public Subscription awaitCatchup() throws SubscriptionCancelledException { try { catchup.get(); } catch (InterruptedException | ExecutionException e) { throw new SubscriptionCancelledException(e); } return this; } @Override void close(); @Override Subs...
### Question: SubscriptionImpl implements Subscription { @Override public Subscription awaitComplete() throws SubscriptionCancelledException { try { complete.get(); } catch (InterruptedException | ExecutionException e) { throw new SubscriptionCancelledException(e); } return this; } @Override void close(); @Override Su...
### Question: SubscriptionImpl implements Subscription { public void notifyElement(@NonNull T e) { if (!closed.get()) { observer.onNext(e); } } @Override void close(); @Override Subscription awaitCatchup(); Subscription awaitCatchup(long waitTimeInMillis); @Override Subscription awaitComplete(); Subscription awaitComp...
### Question: SubscriptionImpl implements Subscription { public void notifyError(Throwable e) { if (!closed.get()) { observer.onError(e); if (!catchup.isDone()) { catchup.completeExceptionally(e); } if (!complete.isDone()) { complete.completeExceptionally(e); } tryClose(); } } @Override void close(); @Override Subscri...
### Question: SubscriptionImpl implements Subscription { public SubscriptionImpl<T> onClose(Runnable e) { onClose = e; return this; } @Override void close(); @Override Subscription awaitCatchup(); Subscription awaitCatchup(long waitTimeInMillis); @Override Subscription awaitComplete(); Subscription awaitComplete(long ...
### Question: SubscriptionImpl implements Subscription { public static <T> SubscriptionImpl<T> on(@NonNull GenericObserver<T> o) { return new SubscriptionImpl<>(o); } @Override void close(); @Override Subscription awaitCatchup(); Subscription awaitCatchup(long waitTimeInMillis); @Override Subscription awaitComplete();...
### Question: ReconnectingFactSubscriptionWrapper implements Subscription { @Override public Subscription awaitComplete() throws SubscriptionCancelledException { for (;;) { assertSubscriptionStateNotClosed(); Subscription cur = currentSubscription.get(); if (cur != null) { try { cur.awaitComplete(); return this; } catc...
### Question: ReconnectingFactSubscriptionWrapper implements Subscription { @Override public Subscription awaitCatchup() throws SubscriptionCancelledException { for (;;) { assertSubscriptionStateNotClosed(); Subscription cur = currentSubscription.get(); if (cur != null) { try { cur.awaitCatchup(); return this; } catch ...
### Question: ReconnectingFactSubscriptionWrapper implements Subscription { private void assertSubscriptionStateNotClosed() { if (closed.get()) { throw new SubscriptionCancelledException("Subscription already cancelled"); } } ReconnectingFactSubscriptionWrapper(@NonNull FactStore store, @NonNull Subscriptio...
### Question: FluentSubscriptionRequest implements SubscriptionRequest { @Override public String toString() { return debugInfo; } FluentSubscriptionRequest(); @Override java.util.Optional<UUID> startingAfter(); @Override String toString(); }### Answer: @Test void testToString() { SubscriptionRequest r = SubscriptionRe...
### Question: SubscriptionRequestTO implements SubscriptionRequest { public static SubscriptionRequestTO forFacts(SubscriptionRequest request) { SubscriptionRequestTO t = new SubscriptionRequestTO(request); t.idOnly(false); return t; } SubscriptionRequestTO(SubscriptionRequest request); boolean hasAnyScriptFilters(); @...
### Question: SubscriptionRequestTO implements SubscriptionRequest { @Override public String toString() { return debugInfo; } SubscriptionRequestTO(SubscriptionRequest request); boolean hasAnyScriptFilters(); @Override java.util.Optional<UUID> startingAfter(); static SubscriptionRequestTO forFacts(SubscriptionRequest r...
### Question: SubscriptionRequestTO implements SubscriptionRequest { public boolean hasAnyScriptFilters() { return specs.stream().anyMatch(s -> s.jsFilterScript() != null); } SubscriptionRequestTO(SubscriptionRequest request); boolean hasAnyScriptFilters(); @Override java.util.Optional<UUID> startingAfter(); static Sub...
### Question: SubscriptionRequestTO implements SubscriptionRequest { public void addSpecs(@NonNull List<FactSpec> factSpecs) { checkArgument(!factSpecs.isEmpty()); specs.addAll(factSpecs); } SubscriptionRequestTO(SubscriptionRequest request); boolean hasAnyScriptFilters(); @Override java.util.Optional<UUID> startingAft...
### Question: Lz4GrpcServerCodec implements Codec { @Override public String getMessageEncoding() { return "lz4"; } @Override String getMessageEncoding(); @Override InputStream decompress(InputStream inputStream); @Override OutputStream compress(OutputStream outputStream); }### Answer: @Test void getMessageEncoding() ...
### Question: SnappyGrpcServerCodec implements Codec { @Override public String getMessageEncoding() { return "snappy"; } @Override String getMessageEncoding(); @Override InputStream decompress(InputStream inputStream); @Override OutputStream compress(OutputStream outputStream); }### Answer: @Test void getMessageEncod...
### Question: BlockingStreamObserver implements StreamObserver<T> { @Override public void onCompleted() { delegate.onCompleted(); } BlockingStreamObserver(@NonNull String id, @NonNull ServerCallStreamObserver<T> delegate); @Override void onNext(T value); @Override void onError(Throwable t); @Override void onCompleted()...
### Question: BlockingStreamObserver implements StreamObserver<T> { @Override public void onError(Throwable t) { delegate.onError(t); } BlockingStreamObserver(@NonNull String id, @NonNull ServerCallStreamObserver<T> delegate); @Override void onNext(T value); @Override void onError(Throwable t); @Override void onComplet...
### Question: PgConfigurationProperties implements ApplicationListener<ApplicationReadyEvent> { public int getQueueSizeForIds() { return queueSize * idOnlyFactor; } int getPageSizeForIds(); int getQueueSizeForIds(); int getFetchSizeForIds(); int getFetchSize(); @Override void onApplicationEvent(ApplicationReadyEvent e...
### Question: BlockingStreamObserver implements StreamObserver<T> { @Override public void onNext(T value) { if (!delegate.isCancelled()) { synchronized (lock) { if (!delegate.isReady()) { for (int i = 1; i <= RETRY_COUNT; i++) { log.debug("{} channel not ready. Slow client? Attempt: {}/{}", id, i, RETRY_COUNT); try { l...
### Question: FactStoreGrpcService extends RemoteFactStoreImplBase { @Override public void handshake(MSG_Empty request, StreamObserver<MSG_ServerConfig> responseObserver) { ServerConfig cfg = ServerConfig.of(PROTOCOL_VERSION, collectProperties()); responseObserver.onNext(converter.toProto(cfg)); responseObserver.onComp...
### Question: GrpcCompressionInterceptor implements ServerInterceptor { @Override public <ReqT, RespT> Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> call, Metadata headers, ServerCallHandler<ReqT, RespT> next) { codecs.selectFrom(headers.get(GRPC_ACCEPT_ENCODING)).ifPresent(c -> { call.setCompression(c); call.se...
### Question: GrpcObserverAdapter implements FactObserver { @Override public void onComplete() { log.info("{} onComplete – sending complete notification", id); observer.onNext(converter.createCompleteNotification()); tryComplete(); } @Override void onComplete(); @Override void onError(Throwable e); @Override void onCa...
### Question: GrpcObserverAdapter implements FactObserver { @Override public void onCatchup() { log.info("{} onCatchup – sending catchup notification", id); observer.onNext(converter.createCatchupNotification()); } @Override void onComplete(); @Override void onError(Throwable e); @Override void onCatchup(); @Override ...
### Question: GrpcObserverAdapter implements FactObserver { @Override public void onError(Throwable e) { log.warn("{} onError – sending Error notification {}", id, e.getMessage()); observer.onError(e); tryComplete(); } @Override void onComplete(); @Override void onError(Throwable e); @Override void onCatchup(); @Overr...
### Question: GrpcObserverAdapter implements FactObserver { @Override public void onNext(Fact element) { observer.onNext(projection.apply(element)); } @Override void onComplete(); @Override void onError(Throwable e); @Override void onCatchup(); @Override void onNext(Fact element); }### Answer: @Test void testOnNext()...
### Question: PgListener implements InitializingBean, DisposableBean { @Override public void destroy() { this.running.set(false); if (listenerThread != null) { listenerThread.interrupt(); } } @Override void afterPropertiesSet(); @Override void destroy(); }### Answer: @Test void testStopWithoutStarting() { PgListener ...
### Question: PgConnectionSupplier { @VisibleForTesting Properties buildPgConnectionProperties(org.apache.tomcat.jdbc.pool.DataSource ds) { Properties dbp = new Properties(); final PoolConfiguration poolProperties = ds.getPoolProperties(); if (poolProperties != null) { setProperty(dbp, "user", poolProperties.getUsernam...
### Question: RdsDataSourceFactoryBeanPostProcessor implements BeanPostProcessor { @Override @NonNull public Object postProcessAfterInitialization(@NonNull Object bean, @NonNull String beanName) throws BeansException { return bean; } @Override @NonNull Object postProcessBeforeInitialization(@NonNull Object bean, @NonN...
### Question: RdsDataSourceFactoryBeanPostProcessor implements BeanPostProcessor { @Override @NonNull public Object postProcessBeforeInitialization(@NonNull Object bean, @NonNull String beanName) throws BeansException { if (bean instanceof AmazonRdsDataSourceFactoryBean) { ((AmazonRdsDataSourceFactoryBean) bean).setDat...
### Question: PgConfigurationProperties implements ApplicationListener<ApplicationReadyEvent> { public int getFetchSizeForIds() { return getQueueSizeForIds() / queueFetchRatio; } int getPageSizeForIds(); int getQueueSizeForIds(); int getFetchSizeForIds(); int getFetchSize(); @Override void onApplicationEvent(Applicati...
### Question: InMemFact extends DefaultFact { @Override public String toString() { return FactCastJson.writeValueAsPrettyString(this); } InMemFact(long ser, Fact toCopyFrom); @Override String toString(); }### Answer: @Test public void testToString() throws Exception { Fact f = Fact.of("{\"ns\":\"someNs\",\"id\":\"" + ...
### Question: Catchup implements Command { @Override public void runWith(FactCast fc, Options opt) { ConsoleFactObserver obs = new ConsoleFactObserver(opt); SpecBuilder catchup = SubscriptionRequest.catchup(FactSpec.ns(ns)); if (from == null) fc.subscribeEphemeral(catchup.fromScratch(), obs); else fc.subscribeEphemeral...