method2testcases
stringlengths
118
6.63k
### Question: WxPayServiceImpl implements WxPayService { @Override public WxPayRefundResult refund(WxPayRefundRequest request) throws WxPayException { request.checkAndSign(this.getConfig()); String url = this.getPayBaseUrl() + "/secapi/pay/refund"; String responseContent = this.postWithKey(url, request.toXML()); WxPayR...
### Question: WxPayServiceImpl implements WxPayService { @Override public WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, String outRefundNo, String refundId) throws WxPayException { WxPayRefundQueryRequest request = new WxPayRefundQueryRequest(); request.setOutTradeNo(StringUtils.trimToNull...
### Question: WxPayServiceImpl implements WxPayService { @Override public WxPaySendRedpackResult sendRedpack(WxPaySendRedpackRequest request) throws WxPayException { request.checkAndSign(this.getConfig()); String url = this.getPayBaseUrl() + "/mmpaymkttransfers/sendredpack"; if (request.getAmtType() != null) { url = th...
### Question: WxPayServiceImpl implements WxPayService { @Override public WxPayRedpackQueryResult queryRedpack(String mchBillNo) throws WxPayException { WxPayRedpackQueryRequest request = new WxPayRedpackQueryRequest(); request.setMchBillNo(mchBillNo); request.setBillType("MCHT"); request.checkAndSign(this.getConfig())...
### Question: WxCpDepartmentServiceImpl implements WxCpDepartmentService { @Override public void update(WxCpDepart group) throws WxErrorException { String url = "https: this.mainService.post(url, group.toJson()); } WxCpDepartmentServiceImpl(WxCpService mainService); @Override Integer create(WxCpDepart depart); @Overrid...
### Question: WxPayServiceImpl implements WxPayService { @Override public WxPayUnifiedOrderResult unifiedOrder(WxPayUnifiedOrderRequest request) throws WxPayException { request.checkAndSign(this.getConfig()); String url = this.getPayBaseUrl() + "/pay/unifiedorder"; String responseContent = this.post(url, request.toXML(...
### Question: WxPayServiceImpl implements WxPayService { @Override public WxPayOrderQueryResult queryOrder(String transactionId, String outTradeNo) throws WxPayException { WxPayOrderQueryRequest request = new WxPayOrderQueryRequest(); request.setOutTradeNo(StringUtils.trimToNull(outTradeNo)); request.setTransactionId(S...
### Question: WxPayServiceImpl implements WxPayService { @Override public WxPayOrderCloseResult closeOrder(String outTradeNo) throws WxPayException { if (StringUtils.isBlank(outTradeNo)) { throw new IllegalArgumentException("out_trade_no不能为空"); } WxPayOrderCloseRequest request = new WxPayOrderCloseRequest(); request.se...
### Question: WxPayServiceImpl implements WxPayService { @Override public WxEntPayResult entPay(WxEntPayRequest request) throws WxPayException { request.checkAndSign(this.getConfig()); String url = this.getPayBaseUrl() + "/mmpaymkttransfers/promotion/transfers"; String responseContent = this.postWithKey(url, request.to...
### Question: WxPayServiceImpl implements WxPayService { @Override public WxEntPayQueryResult queryEntPay(String partnerTradeNo) throws WxPayException { WxEntPayQueryRequest request = new WxEntPayQueryRequest(); request.setPartnerTradeNo(partnerTradeNo); request.checkAndSign(this.getConfig()); String url = this.getPayB...
### Question: WxPayServiceImpl implements WxPayService { @Override public byte[] createScanPayQrcodeMode1(String productId, File logoFile, Integer sideLength) { String content = this.createScanPayQrcodeMode1(productId); return this.createQrcode(content, logoFile, sideLength); } @Override WxPayConfig getConfig(); @Over...
### Question: WxPayServiceImpl implements WxPayService { @Override public byte[] createScanPayQrcodeMode2(String codeUrl, File logoFile, Integer sideLength) { return this.createQrcode(codeUrl, logoFile, sideLength); } @Override WxPayConfig getConfig(); @Override void setConfig(WxPayConfig config); @Override WxPayRefun...
### Question: WxPayServiceImpl implements WxPayService { @Override public WxPayOrderNotifyResult getOrderNotifyResult(String xmlData) throws WxPayException { try { log.debug("微信支付回调参数详细:{}", xmlData); WxPayOrderNotifyResult result = WxPayOrderNotifyResult.fromXML(xmlData); log.debug("微信支付回调结果对象:{}", result); result.che...
### Question: WxPayServiceImpl implements WxPayService { @Override public WxPayMicropayResult micropay(WxPayMicropayRequest request) throws WxPayException { request.checkAndSign(this.getConfig()); String url = this.getPayBaseUrl() + "/pay/micropay"; String responseContent = this.post(url, request.toXML(), true); WxPayM...
### Question: WxPayServiceImpl implements WxPayService { @Override public WxPayConfig getConfig() { return this.config; } @Override WxPayConfig getConfig(); @Override void setConfig(WxPayConfig config); @Override WxPayRefundResult refund(WxPayRefundRequest request); @Override WxPayRefundQueryResult refundQuery(String ...
### Question: WxCpDepartmentServiceImpl implements WxCpDepartmentService { @Override public void delete(Integer departId) throws WxErrorException { String url = "https: this.mainService.get(url, null); } WxCpDepartmentServiceImpl(WxCpService mainService); @Override Integer create(WxCpDepart depart); @Override void upda...
### Question: WxPayServiceImpl implements WxPayService { @Override public void setConfig(WxPayConfig config) { this.config = config; } @Override WxPayConfig getConfig(); @Override void setConfig(WxPayConfig config); @Override WxPayRefundResult refund(WxPayRefundRequest request); @Override WxPayRefundQueryResult refund...
### Question: WxPayServiceImpl implements WxPayService { @Override public WxPayOrderReverseResult reverseOrder(WxPayOrderReverseRequest request) throws WxPayException { request.checkAndSign(this.getConfig()); String url = this.getPayBaseUrl() + "/secapi/pay/reverse"; String responseContent = this.postWithKey(url, reque...
### Question: WxPayServiceImpl implements WxPayService { @Override public String shorturl(WxPayShorturlRequest request) throws WxPayException { request.checkAndSign(this.getConfig()); String url = this.getPayBaseUrl() + "/tools/shorturl"; String responseContent = this.post(url, request.toXML(), true); WxPayShorturlResu...
### Question: WxPayServiceImpl implements WxPayService { @Override public String authcode2Openid(WxPayAuthcode2OpenidRequest request) throws WxPayException { request.checkAndSign(this.getConfig()); String url = this.getPayBaseUrl() + "/tools/authcodetoopenid"; String responseContent = this.post(url, request.toXML(), tr...
### Question: WxPayServiceImpl implements WxPayService { @Override public String getSandboxSignKey() throws WxPayException { WxPayDefaultRequest request = new WxPayDefaultRequest(); request.checkAndSign(this.getConfig()); String url = "https: String responseContent = this.post(url, request.toXML(), false); WxPaySandbox...
### Question: WxPayConfig { public SSLContext initSSLContext() throws WxPayException { if (StringUtils.isBlank(mchId)) { throw new IllegalArgumentException("请确保商户号mchId已设置"); } if (StringUtils.isBlank(this.keyPath)) { throw new IllegalArgumentException("请确保证书文件地址keyPath已配置"); } InputStream inputStream; final String pre...
### Question: WxPaySendRedpackResult extends WxPayBaseResult implements Serializable { public String getSendTime() { return this.sendTime; } String getMchBillno(); void setMchBillno(String mchBillno); String getWxappid(); void setWxappid(String wxappid); String getReOpenid(); void setReOpenid(String reOpenid); int get...
### Question: WxPayBaseResult { protected String getXmlValue(String... path) { Document doc = this.getXmlDoc(); String expression = String.format("/%s try { return (String) XPathFactory .newInstance() .newXPath() .compile(expression) .evaluate(doc, XPathConstants.STRING); } catch (XPathExpressionException e) { throw ne...
### Question: WxCpMenuServiceImpl implements WxCpMenuService { @Override public void create(WxMenu menu) throws WxErrorException { this.create(this.mainService.getWxCpConfigStorage().getAgentId(), menu); } WxCpMenuServiceImpl(WxCpService mainService); @Override void create(WxMenu menu); @Override void create(Integer ag...
### Question: SHA1 { public static String gen(String... arr) { if (StringUtils.isAnyEmpty(arr)) { throw new IllegalArgumentException("非法请求参数,有部分参数为空 : " + Arrays.toString(arr)); } Arrays.sort(arr); StringBuilder sb = new StringBuilder(); for (String a : arr) { sb.append(a); } return DigestUtils.sha1Hex(sb.toString()); ...
### Question: SHA1 { public static String genWithAmple(String... arr) { if (StringUtils.isAnyEmpty(arr)) { throw new IllegalArgumentException("非法请求参数,有部分参数为空 : " + Arrays.toString(arr)); } Arrays.sort(arr); StringBuilder sb = new StringBuilder(); for (int i = 0; i < arr.length; i++) { String a = arr[i]; sb.append(a); i...
### Question: WxMaMsgServiceImpl implements WxMaMsgService { @Override public String sendTemplateMsg(WxMaTemplateMessage templateMessage) throws WxErrorException { String responseContent = this.wxMaService.post(TEMPLATE_MSG_SEND_URL, templateMessage.toJson()); JsonObject jsonObject = JSON_PARSER.parse(responseContent)....
### Question: WxMaUserServiceImpl implements WxMaUserService { @Override public WxMaJscode2SessionResult getSessionInfo(String jsCode) throws WxErrorException { final WxMaConfig config = service.getWxMaConfig(); Map<String, String> params = new HashMap<>(); params.put("appid", config.getAppid()); params.put("secret", c...
### Question: WxMaUserServiceImpl implements WxMaUserService { @Override public WxMaUserInfo getUserInfo(String sessionKey, String encryptedData, String ivStr) { return WxMaUserInfo.fromJson(WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr)); } WxMaUserServiceImpl(WxMaService service); @Override WxMaJscode2Sessi...
### Question: WxMaUserServiceImpl implements WxMaUserService { @Override public boolean checkUserInfo(String sessionKey, String rawData, String signature) { final String generatedSignature = DigestUtils.sha1Hex(rawData + sessionKey); System.out.println(generatedSignature); return generatedSignature.equals(signature); }...
### Question: WxMaQrcodeServiceImpl implements WxMaQrcodeService { @Override public File createQrcode(String path, int width) throws WxErrorException { String url = "https: return this.wxMaService.execute(new QrCodeRequestExecutor(this.wxMaService.getRequestHttp()), url, new WxMaQrcode(path, width)); } WxMaQrcodeServic...
### Question: WxCpMenuServiceImpl implements WxCpMenuService { @Override public WxMenu get() throws WxErrorException { return this.get(this.mainService.getWxCpConfigStorage().getAgentId()); } WxCpMenuServiceImpl(WxCpService mainService); @Override void create(WxMenu menu); @Override void create(Integer agentId, WxMenu ...
### Question: WxMaMediaServiceImpl implements WxMaMediaService { @Override public WxMediaUploadResult uploadMedia(String mediaType, String fileType, InputStream inputStream) throws WxErrorException { try { return this.uploadMedia(mediaType, FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), fileType)); ...
### Question: WxMaMediaServiceImpl implements WxMaMediaService { @Override public File getMedia(String mediaId) throws WxErrorException { try { RequestExecutor<File, String> executor = MediaDownloadRequestExecutor .create(this.wxMaService.getRequestHttp(), Files.createTempDirectory("wxma").toFile()); return this.wxMaSe...
### Question: WxMaTemplateMessage implements Serializable { public String toJson() { return WxMaGsonBuilder.create().toJson(this); } private WxMaTemplateMessage(Builder builder); static Builder newBuilder(); String toJson(); String getToUser(); void setToUser(String toUser); String getTemplateId(); void setTemplateId(...
### Question: WxMpMessageRouter { public WxMpMessageRouterRule rule() { return new WxMpMessageRouterRule(this); } WxMpMessageRouter(WxMpService wxMpService); void setExecutorService(ExecutorService executorService); void setMessageDuplicateChecker(WxMessageDuplicateChecker messageDuplicateChecker); void setSessionManag...
### Question: WxMpMessageRouter { public WxMpXmlOutMessage route(final WxMpXmlMessage wxMessage, final Map<String, Object> context) { if (isMsgDuplicated(wxMessage)) { return null; } final List<WxMpMessageRouterRule> matchRules = new ArrayList<>(); for (final WxMpMessageRouterRule rule : this.rules) { if (rule.test(wxM...
### Question: WxMpUserBlacklistServiceImpl implements WxMpUserBlacklistService { @Override public WxMpUserBlacklistGetResult getBlacklist(String nextOpenid) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("begin_openid", nextOpenid); String url = API_BLACKLIST_PREFIX + "/getbl...
### Question: WxMpUserBlacklistServiceImpl implements WxMpUserBlacklistService { @Override public void pushToBlacklist(List<String> openidList) throws WxErrorException { Map<String, Object> map = new HashMap<>(); map.put("openid_list", openidList); String url = API_BLACKLIST_PREFIX + "/batchblacklist"; this.wxMpService...
### Question: WxMpUserBlacklistServiceImpl implements WxMpUserBlacklistService { @Override public void pullFromBlacklist(List<String> openidList) throws WxErrorException { Map<String, Object> map = new HashMap<>(); map.put("openid_list", openidList); String url = API_BLACKLIST_PREFIX + "/batchunblacklist"; this.wxMpSer...
### Question: WxMpDeviceServiceImpl implements WxMpDeviceService { @Override public WxDeviceQrCodeResult getQrCode(String productId) throws WxErrorException { String url = API_URL_PREFIX + "/getqrcode"; String response = this.wxMpService.get(url, "product_id=" + productId); return WxDeviceQrCodeResult.fromJson(response...
### Question: WxCpMenuServiceImpl implements WxCpMenuService { @Override public void delete() throws WxErrorException { this.delete(this.mainService.getWxCpConfigStorage().getAgentId()); } WxCpMenuServiceImpl(WxCpService mainService); @Override void create(WxMenu menu); @Override void create(Integer agentId, WxMenu men...
### Question: WxMpCardServiceImpl implements WxMpCardService { @Override public String getCardApiTicket() throws WxErrorException { return getCardApiTicket(false); } WxMpCardServiceImpl(WxMpService wxMpService); @Override WxMpService getWxMpService(); @Override String getCardApiTicket(); @Override String getCardApiTick...
### Question: WxMpCardServiceImpl implements WxMpCardService { @Override public WxCardApiSignature createCardApiSignature(String... optionalSignParam) throws WxErrorException { long timestamp = System.currentTimeMillis() / 1000; String nonceStr = RandomUtils.getRandomStr(); String cardApiTicket = getCardApiTicket(false...
### Question: WxMpCardServiceImpl implements WxMpCardService { @Override public String decryptCardCode(String encryptCode) throws WxErrorException { JsonObject param = new JsonObject(); param.addProperty("encrypt_code", encryptCode); String responseContent = this.wxMpService.post(CARD_CODE_DECRYPT, param.toString()); J...
### Question: WxMpCardServiceImpl implements WxMpCardService { @Override public WxMpCardResult queryCardCode(String cardId, String code, boolean checkConsume) throws WxErrorException { JsonObject param = new JsonObject(); param.addProperty("card_id", cardId); param.addProperty("code", code); param.addProperty("check_co...
### Question: WxMpCardServiceImpl implements WxMpCardService { @Override public String consumeCardCode(String code) throws WxErrorException { return consumeCardCode(code, null); } WxMpCardServiceImpl(WxMpService wxMpService); @Override WxMpService getWxMpService(); @Override String getCardApiTicket(); @Override String ...
### Question: WxMpCardServiceImpl implements WxMpCardService { @Override public void markCardCode(String code, String cardId, String openId, boolean isMark) throws WxErrorException { JsonObject param = new JsonObject(); param.addProperty("code", code); param.addProperty("card_id", cardId); param.addProperty("openid", o...
### Question: WxMpCardServiceImpl implements WxMpCardService { @Override public String getCardDetail(String cardId) throws WxErrorException { JsonObject param = new JsonObject(); param.addProperty("card_id", cardId); String responseContent = this.wxMpService.post(CARD_GET, param.toString()); JsonObject json = (new Json...
### Question: WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService { @Override public String sendTemplateMsg(WxMpTemplateMessage templateMessage) throws WxErrorException { String url = "https: String responseContent = this.wxMpService.post(url, templateMessage.toJson()); final JsonObject jsonObject = JSON_PARSE...
### Question: WxCpTagServiceImpl implements WxCpTagService { @Override public String create(String tagName) throws WxErrorException { String url = "https: JsonObject o = new JsonObject(); o.addProperty("tagname", tagName); String responseContent = this.mainService.post(url, o.toString()); JsonElement tmpJsonElement = n...
### Question: WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService { @Override public WxMpTemplateIndustry getIndustry() throws WxErrorException { String url = API_URL_PREFIX + "/get_industry"; String responseContent = this.wxMpService.get(url, null); return WxMpTemplateIndustry.fromJson(responseContent); } WxM...
### Question: WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService { @Override public boolean setIndustry(WxMpTemplateIndustry wxMpIndustry) throws WxErrorException { if (null == wxMpIndustry.getPrimaryIndustry() || null == wxMpIndustry.getPrimaryIndustry().getId() || null == wxMpIndustry.getSecondIndustry() ||...
### Question: WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService { @Override public String addTemplate(String shortTemplateId) throws WxErrorException { String url = API_URL_PREFIX + "/api_add_template"; JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("template_id_short", shortTemplateId); St...
### Question: WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService { @Override public List<WxMpTemplate> getAllPrivateTemplate() throws WxErrorException { String url = API_URL_PREFIX + "/get_all_private_template"; return WxMpTemplate.fromJson(this.wxMpService.get(url, null)); } WxMpTemplateMsgServiceImpl(WxMpSe...
### Question: WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService { @Override public boolean delPrivateTemplate(String templateId) throws WxErrorException { String url = API_URL_PREFIX + "/del_private_template"; JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("template_id", templateId); String...
### Question: WxCpTagServiceImpl implements WxCpTagService { @Override public void update(String tagId, String tagName) throws WxErrorException { String url = "https: JsonObject o = new JsonObject(); o.addProperty("tagid", tagId); o.addProperty("tagname", tagName); this.mainService.post(url, o.toString()); } WxCpTagSer...
### Question: WxMpKefuServiceImpl implements WxMpKefuService { @Override public WxMpKfMsgList kfMsgList(Date startTime, Date endTime, Long msgId, Integer number) throws WxErrorException { if (number > 10000) { throw new WxErrorException(WxError.newBuilder().setErrorMsg("非法参数请求,每次最多查询10000条记录!").build()); } if (startTim...
### Question: WxMpDataCubeServiceImpl implements WxMpDataCubeService { @Override public List<WxDataCubeUserSummary> getUserSummary(Date beginDate, Date endDate) throws WxErrorException { String responseContent = this.wxMpService.post(GET_USER_SUMMARY, buildParams(beginDate, endDate)); return WxDataCubeUserSummary.fromJ...
### Question: WxMpDataCubeServiceImpl implements WxMpDataCubeService { @Override public List<WxDataCubeUserCumulate> getUserCumulate(Date beginDate, Date endDate) throws WxErrorException { String responseContent = this.wxMpService.post(GET_USER_CUMULATE, buildParams(beginDate, endDate)); return WxDataCubeUserCumulate.f...
### Question: WxMpDataCubeServiceImpl implements WxMpDataCubeService { @Override public List<WxDataCubeArticleResult> getArticleSummary(Date beginDate, Date endDate) throws WxErrorException { return this.getArticleResults(GET_ARTICLE_SUMMARY, beginDate, endDate); } WxMpDataCubeServiceImpl(WxMpService wxMpService); @Ove...
### Question: WxCpTagServiceImpl implements WxCpTagService { @Override public List<WxCpTag> listAll() throws WxErrorException { String url = "https: String responseContent = this.mainService.get(url, null); JsonElement tmpJsonElement = new JsonParser().parse(responseContent); return WxCpGsonBuilder.INSTANCE.create() .f...
### Question: VerticaBulkLoader extends BaseStep implements StepInterface { @VisibleForTesting VerticaConnection getVerticaConnection() throws SQLException { Connection conn = data.db.getConnection(); if ( conn != null ) { if ( conn instanceof VerticaConnection ) { return (VerticaConnection) conn; } else { Connection u...
### Question: StreamEncoder { public ByteBuffer getBuffer() { return this.buffer; } StreamEncoder( List<ColumnSpec> columns, PipedInputStream inputStream ); void close(); void writeHeader(); void writeRow( RowMetaInterface rowMeta, Object[] row ); ByteBuffer getBuffer(); static final int NUM_ROWS_TO_BUFFER; }### Answer...
### Question: StreamEncoder { int countMainByteBufferSize() { long bufferSize = (long) getRowMaxSize() * NUM_ROWS_TO_BUFFER; return (int) ( bufferSize > 0 && bufferSize < MAXIMUM_BUFFER_SIZE ? bufferSize : MAXIMUM_BUFFER_SIZE ); } StreamEncoder( List<ColumnSpec> columns, PipedInputStream inputStream ); void close(); vo...
### Question: GreeterService extends GreeterGrpc.GreeterImplBase { @Override public void sayHello(HelloRequest request, StreamObserver<HelloReply> responseObserver) { log.info("get request - {}", request.getName()); HelloReply helloReply = HelloReply .newBuilder() .setMessage(String.format("hello %s", request.getName()...
### Question: TransportClientProvider implements Provider<TransportClient> { public TransportClient get() { final String hostCsv = configuration.getString(CONFIG_ES_CLUSTER_HOST); final List<String> hosts = Splitter.on(",").splitToList(hostCsv); Preconditions.checkState(!hosts.isEmpty()); final TransportClient transpor...
### Question: ProductReadService extends ProductReadServiceGrpc.ProductReadServiceImplBase { @Override public void searchProducts(SearchProductsRequest request, StreamObserver<SearchProductsResponse> responseObserver) { try { responseObserver.onNext(productDao.searchProducts(request)); responseObserver.onCompleted(); c...
### Question: ProductReadService extends ProductReadServiceGrpc.ProductReadServiceImplBase { @Override public void downloadProducts(DownloadProductsRequest request, StreamObserver<Product> responseObserver) { PublishSubject<Product> productPublishSubject = PublishSubject.create(); productPublishSubject .doOnNext(produc...
### Question: ProductReadService extends ProductReadServiceGrpc.ProductReadServiceImplBase { @Override public StreamObserver<Product> calculateProductScore(StreamObserver<CalculateProductScoreResponse> responseObserver) { PublishSubject<CalculateProductScoreResponse> downloadStream = PublishSubject.create(); downloadSt...
### Question: ProductReadService extends ProductReadServiceGrpc.ProductReadServiceImplBase { @Override public void downloadProductImage(DownloadProductImageRequest request, StreamObserver<DataChunk> responseObserver) { try { BufferedInputStream imageStream = new BufferedInputStream( productImageSeeker.seekProductImage(...
### Question: ProductUpdateService extends ProductUpdateServiceGrpc.ProductUpdateServiceImplBase { @Override public StreamObserver<Product> uploadProduct(StreamObserver<UploadProductResponse> responseObserver) { PublishSubject<Product> publishSubject = PublishSubject.create(); publishSubject .doOnNext(product -> { log....
### Question: RxStreamObserver implements StreamObserver<T> { @Override public void onError(Throwable t) { observer.onError(t); } RxStreamObserver(Observer<T> observer); @Override void onNext(T value); @Override void onError(Throwable t); @Override void onCompleted(); }### Answer: @Test public void clientStreaming_err...
### Question: EchoService extends EchoServiceGrpc.EchoServiceImplBase { @Override public void echo(EchoRequest request, StreamObserver<EchoResponse> responseObserver) { responseObserver.onNext(EchoResponse.newBuilder().setPong(request.getPing()).build()); responseObserver.onCompleted(); } @Override void echo(EchoReque...
### Question: ProductDao { public boolean initIndexIfNotExists() throws IOException { final IndicesExistsResponse existsResponse = esClient.admin().indices().prepareExists(INDEX).get(); if (existsResponse.isExists()) { return false; } final String settings = Resources.toString( getClass().getResource("/elasticsearch/pr...
### Question: Metric { abstract Class service(); static Builder builder(); }### Answer: @Test public void service() throws Exception { assertThat(metric.service()).isAssignableFrom(MetricTest.class); }
### Question: ProductDao { public void upsertProduct(Product product) throws InvalidProtocolBufferException { log.debug("save product into ES"); final UpdateRequestBuilder updateRequestBuilder = esClient .prepareUpdate(INDEX, TYPE, String.valueOf(product.getProductId())) .setDoc( jsonPrinter .includingDefaultValueField...
### Question: ProductDao { public SearchProductsResponse searchProducts(SearchProductsRequest request) throws InvalidProtocolBufferException { QueryBuilder queryBuilder = QueryBuilders.boolQuery() .must(QueryBuilders.matchQuery("productName", request.getKeyWord())); SearchResponse response = esClient.prepareSearch(INDE...
### Question: ProductDao { public void downloadProducts(DownloadProductsRequest request, PublishSubject<Product> productPublishSubject) { QueryBuilder queryBuilder = QueryBuilders.termQuery("category", request.getCategory()); SearchResponse scrollResponse = esClient .prepareSearch(INDEX) .setScroll(DEFAULT_SCROLL_TIME_...
### Question: ProductDao { public void calculateProductScore(Product product, PublishSubject<CalculateProductScoreResponse> downloadStream) { downloadStream.onNext( CalculateProductScoreResponse .newBuilder() .setProduct(product) .setScore((long) product.getProductPrice()) .build() ); } void upsertProduct(Product prod...
### Question: Metric { abstract Optional<String> action(); static Builder builder(); }### Answer: @Test public void action() throws Exception { assertThat(metric.action().get()).isEqualTo("test"); }
### Question: Metric { abstract Optional<List<String>> labels(); static Builder builder(); }### Answer: @Test public void labels() throws Exception { assertThat(metric.labels()).isNotEmpty(); assertThat(metric.labels().get()).contains("labela", "labelb"); }
### Question: Metric { public static Builder builder() { return new AutoValue_Metric.Builder(); } static Builder builder(); }### Answer: @Test(expected = IllegalStateException.class) public void mandatory_field() throws Exception { metric = Metric .builder() .build(); fail("should failed as mandatory field is missing...
### Question: CounterFactory { public static Counter create(final Metric metric) { return cachedCounter.getUnchecked(metric); } static Counter create(final Metric metric); }### Answer: @Test public void create() throws Exception { Counter counter1 = CounterFactory.create( Metric.builder() .setService(CounterFactoryTe...
### Question: ConfigurationProvider implements Provider<Configuration> { @Override public Configuration get() { Configurations configs = new Configurations(); try { return configs.properties(new File(getPropertyFilePath())); } catch (ConfigurationException e) { log.error(" error on build configuration", e); throw new I...
### Question: ConfigurationProvider implements Provider<Configuration> { public String getPropertyFilePath() { return propertyFilePath; } ConfigurationProvider(); @Override Configuration get(); String getPropertyFilePath(); }### Answer: @Test public void getPropertyFilePath() throws Exception { assertThat(configuratio...
### Question: ElasticSearchModule extends AbstractModule { @Override protected void configure() { bind(Configuration.class).toProvider(ConfigurationProvider.class).in(Singleton.class); bind(TransportClient.class).toProvider(TransportClientProvider.class).in(Singleton.class); bind(JsonFormat.Printer.class).toInstance(Js...
### Question: LoginViewModel extends BaseViewModel<LoginNavigator> { public void login(String email, String password) { setIsLoading(true); getCompositeDisposable().add(getDataManager() .doServerLoginApiCall(new LoginRequest.ServerLoginRequest(email, password)) .doOnSuccess(response -> getDataManager() .updateUserInfo(...
### Question: HoneycombDOMRpcService implements DOMRpcService { @Nonnull @Override public FluentFuture<DOMRpcResult> invokeRpc(@Nonnull final SchemaPath schemaPath, @Nullable final NormalizedNode<?, ?> normalizedNode) { DataObject input = null; if (normalizedNode != null) { final SchemaPath nodePatch = schemaPath.creat...
### Question: HoneycombNotificationCollector implements NotificationCollector, AutoCloseable { @Override @Nonnull public Collection<Class<? extends Notification>> getNotificationTypes() { return notificationProducerRegistry.getNotificationTypes(); } HoneycombNotificationCollector( @Nonnull final NotificationPub...
### Question: HoneycombNotificationCollector implements NotificationCollector, AutoCloseable { @Override public void onNotification(@Nonnull final Notification notification) { LOG.debug("Notification: {} pushed into collector", notification.getClass().getSimpleName()); LOG.trace("Notification: {} pushed into collector"...
### Question: NotificationProducerRegistry { Set<Class<? extends Notification>> getNotificationTypes() { return notificationTypes; } NotificationProducerRegistry(final List<ManagedNotificationProducer> notificationProducersDependency); static QName getQName(final Class<? extends Notification> aClass); }### Answer: @Te...
### Question: PersistingDataTreeAdapter implements DataTree { @Override public DataTreeSnapshot takeSnapshot() { return delegateDependency.takeSnapshot(); } PersistingDataTreeAdapter(@Nonnull final DataTree delegate, @Nonnull final DOMSchemaService schemaService, ...
### Question: PersistingDataTreeAdapter implements DataTree { @Override public void setSchemaContext(final SchemaContext schemaContext) { delegateDependency.setSchemaContext(schemaContext); } PersistingDataTreeAdapter(@Nonnull final DataTree delegate, @Nonnull final DOMSchemaService...
### Question: PersistingDataTreeAdapter implements DataTree { @Override public void validate(final DataTreeModification dataTreeModification) throws DataValidationFailedException { delegateDependency.validate(dataTreeModification); } PersistingDataTreeAdapter(@Nonnull final DataTree delegate, ...
### Question: PersistingDataTreeAdapter implements DataTree { @Override public DataTreeCandidateTip prepare( final DataTreeModification dataTreeModification) { return delegateDependency.prepare(dataTreeModification); } PersistingDataTreeAdapter(@Nonnull final DataTree delegate, @Non...
### Question: PersistingDataTreeAdapter implements DataTree { @Override public YangInstanceIdentifier getRootPath() { return delegateDependency.getRootPath(); } PersistingDataTreeAdapter(@Nonnull final DataTree delegate, @Nonnull final DOMSchemaService schemaService, ...
### Question: ReadWriteTransaction implements DOMDataTreeReadWriteTransaction, ValidableTransaction { @Override public boolean cancel() { delegateReadTx.close(); return delegateWriteTx.cancel(); } ReadWriteTransaction(@Nonnull final DOMDataTreeReadTransaction delegateReadTx, @Nonnull final Vali...
### Question: ReadWriteTransaction implements DOMDataTreeReadWriteTransaction, ValidableTransaction { @Override public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) { delegateWriteTx.put(store, path, data); } ReadWriteTransaction(@Nonnull final DOMDataTre...