src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
WXSDKEngine { public static boolean registerDomObject(String type, Class<? extends WXDomObject> clazz) throws WXException { return WXDomRegistry.registerDomObject(type, clazz); } @Deprecated static void init(Application application); @Deprecated static void init(Application application, IWXUserTrackAdapter utAdapter);... | @Test public void testRegisterDomObject() throws Exception { assertFalse(WXSDKEngine.registerDomObject("test",null)); assertFalse(WXSDKEngine.registerDomObject("", TestDomObject.class)); assertTrue(WXSDKEngine.registerDomObject("test",TestDomObject.class)); } |
WXSlider extends WXVContainer<FrameLayout> { @Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.VALUE: String value = WXUtils.getString(param, null); if (value != null) { setValue(value); } return true; case Constants.Name.AUTO_PLAY: String aotu_play = WXUtils.getStri... | @Test public void testSetProperties() throws Exception { ComponentTest.setProperty(component,PROPS,VALUES); }
@Test public void testIndicator() throws Exception { WXIndicator indicator = createIndicator(component); ComponentTest.create(indicator); component.addChild(indicator); ComponentTest.setProperty(indicator,IPROP... |
WXSlider extends WXVContainer<FrameLayout> { @WXComponentProp(name = Constants.Name.OFFSET_X_ACCURACY) public void setOffsetXAccuracy(float accuracy) { this.offsetXAccuracy = accuracy; } @Deprecated WXSlider(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXSlider(WXS... | @Test public void testOnScrollListener() throws Exception { component.mViewPager.addOnPageChangeListener(new WXSlider.SliderOnScrollListener(component)); component.setOffsetXAccuracy(0.05f); component.mViewPager.setCurrentItem(0); for (int index=1;index<component.mViewPager.getRealCount();index++) { component.mViewPage... |
WXImage extends WXComponent<ImageView> { @Override protected ImageView initComponentHostView(@NonNull Context context) { WXImageView view = new WXImageView(context); view.setScaleType(ScaleType.FIT_XY); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.setCropToPadding(true); } view.holdComponent(this... | @Test @PrepareForTest(WXImageView.class) public void testInitComponentHostView() throws Exception { ImageView imageView = mWXImage.initComponentHostView(Robolectric.setupActivity(TestActivity.class)); assertEquals(imageView.getClass(), WXImageView.class); }
@Test @PrepareForTest(WXImageView.class) public void testSetBa... |
WXImage extends WXComponent<ImageView> { @Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.RESIZE_MODE: String resize_mode = WXUtils.getString(param, null); if (resize_mode != null) setResizeMode(resize_mode); return true; case Constants.Name.RESIZE: String resize = ... | @Test public void testSetProperty() throws Exception { ImageView imageView = mWXImage.initComponentHostView(Robolectric.setupActivity(TestActivity.class)); mWXImage.mHost = imageView; mWXImage.setProperty(Constants.Name.RESIZE_MODE, "cover"); ImageView.ScaleType scaleType = mWXImage.getHostView().getScaleType(); assert... |
WXSDKInstance implements IWXActivityStateListener,DomContext, View.OnLayoutChangeListener { public void fireEvent(String elementRef,final String type, final Map<String, Object> data,final Map<String, Object> domChanges){ WXBridgeManager.getInstance().fireEventOnNode(getInstanceId(),elementRef,type,data,domChanges); } W... | @Test public void testFireEvent() throws Exception { mInstance.fireEvent("1","test"); Map<String,Object> params = new HashMap<>(); params.put("arg1",null); params.put("arg2",123); mInstance.fireEvent("1","test",params); Map<String,Object> domChange = new HashMap<>(); domChange.put("attr1","123"); mInstance.fireEvent("1... |
WXImage extends WXComponent<ImageView> { @WXComponentProp(name = Constants.Name.RESIZE_MODE) public void setResizeMode(String resizeMode) { (getHostView()).setScaleType(getResizeMode(resizeMode)); } @Deprecated WXImage(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); W... | @Test public void testSetResizeMode() throws Exception { ImageView imageView = mWXImage.initComponentHostView(Robolectric.setupActivity(TestActivity.class)); mWXImage.mHost = imageView; mWXImage.setResizeMode("cover"); ImageView.ScaleType scaleType = mWXImage.getHostView().getScaleType(); assertEquals(scaleType, ImageV... |
WXImage extends WXComponent<ImageView> { @WXComponentProp(name = Constants.Name.RESIZE) public void setResize(String resize) { (getHostView()).setScaleType(getResizeMode(resize)); } @Deprecated WXImage(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXImage(WXSDKInsta... | @Test public void testSetResize() throws Exception { ImageView imageView = mWXImage.initComponentHostView(Robolectric.setupActivity(TestActivity.class)); mWXImage.mHost = imageView; mWXImage.setResize("cover"); ImageView.ScaleType scaleType = mWXImage.getHostView().getScaleType(); assertEquals(scaleType, ImageView.Scal... |
WXImage extends WXComponent<ImageView> { @WXComponentProp(name = Constants.Name.SRC) public void setSrc(String src) { if (src == null) { return; } ImageView image = getHostView(); if("".equals(src) && image != null){ image.setImageDrawable(null); return; } this.mSrc = src; WXSDKInstance instance = getInstance(); Uri re... | @Test public void testSetSrc() throws Exception { TestDomObject.setAttribute((WXDomObject)mWXImage.getDomObject(),PowerMockito.mock(WXAttr.class)); PowerMockito.when(mWXImage.getDomObject().getAttrs().getImageSharpen()).thenReturn(WXImageSharpen.SHARPEN); mWXImage.setSrc(""); } |
WXComponent implements IWXObject, IWXActivityStateListener,OnActivePseudoListner { protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.PREVENT_MOVE_EVENT: if(mGesture != null){ mGesture.setPreventMoveEvent(WXUtils.getBoolean(param,false)); } return true; case Constants.Name.DISA... | @Test public void testSetProperty() throws Exception { assertTrue(component.setProperty(Constants.Name.VISIBILITY,null)); assertTrue(component.setProperty(Constants.Name.VISIBILITY, Constants.Value.VISIBLE)); assertTrue(component.setProperty(Constants.Name.DISABLED,true)); assertTrue(component.setProperty(Constants.Nam... |
WXComponent implements IWXObject, IWXActivityStateListener,OnActivePseudoListner { public void addEvent(String type) { if (TextUtils.isEmpty(type) || mAppendEvents.contains(type)) { return; } mAppendEvents.add(type); View view = getRealView(); if (type.equals(Constants.Event.CLICK) && view != null) { addClickListener(m... | @Test public void testAddEvent() throws Exception { component.addEvent(Constants.Event.FOCUS); } |
WXListComponent extends BasicListComponent<BounceRecyclerView> { @Override public void addChild(WXComponent child, int index) { super.addChild(child, index); if (child == null || index < -1) { return; } setRefreshOrLoading(child); if(mDomObject != null && getHostView() != null && (mColumnWidth != mDomObject.getColumnWi... | @Test public void testAddChild() throws Exception { WXComponent child = WXDivTest.create(component); ComponentTest.create(child); component.addChild(child); child = WXHeaderTest.create(component); ComponentTest.create(child); component.addChild(child); }
@Test public void testScrollTo() throws Exception { WXComponent c... |
DefaultDragHelper implements DragHelper { @Override public void onDragStart(@NonNull WXComponent component, int from) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.d(TAG, "list on drag start : from index " + from); } mEventTrigger.triggerEvent(EVENT_START_DRAG, buildEvent(component.getRef(), from, -1)); } DefaultD... | @Test public void onDragStart() throws Exception { WXComponent c = new WXCell(WXSDKInstanceTest.createInstance(),new TestDomObject(),null,false); mFakeDragHelper.onDragStart(c,3); verify(mockedEventTrigger).triggerEvent(eq("dragstart"),anyMap()); } |
WXSDKInstance implements IWXActivityStateListener,DomContext, View.OnLayoutChangeListener { public void onJSException(final String errCode, final String function, final String exception) { if (mRenderListener != null && mContext != null) { runOnUiThread(new Runnable() { @Override public void run() { if (mRenderListener... | @Test public void testOnJSException() throws Exception { mInstance.onJSException(null,null,null); mInstance.onJSException("100","test","some error"); } |
AnnotationSpans { public static AnnotationSpans extractAnnotationSpans(JCas jCas) { BidiMap sentenceBeginIndexToCharacterIndex = new TreeBidiMap(); BidiMap sentenceEndIndexToCharacterIndex = new TreeBidiMap(); List<Sentence> sentences = new ArrayList<>(JCasUtil.select(jCas, Sentence.class)); for (int i = 0; i < sentenc... | @Test public void extractAnnotationSpans() throws Exception { System.out.println(AnnotationSpans.extractAnnotationSpans(jCas)); } |
BookResource { @DELETE @Path("/{id : \\d+}") @ApiOperation(value = "Delete a Book") @ApiResponses(value = { @ApiResponse(code = 204, message = "Book has been deleted"), @ApiResponse(code = 400, message = "Invalid input") }) public Response delete(@PathParam("id") final Long id) { log.info("Deleting the book " + id); bo... | @Test @InSequence(5) public void delete() throws Exception { final Response response = webTarget.path("{id}") .resolveTemplate("id", 1) .request() .delete(); assertEquals(NO_CONTENT.getStatusCode(), response.getStatus()); } |
NumberResource { @GET @Path("book") @ApiOperation(value = "Generates a book number.", response = String.class) public Response generateBookNumber() throws InterruptedException { final Config config = ConfigProvider.getConfig(); config.getOptionalValue("NUMBER_API_FAKE_TIMEOUT", Integer.class).ifPresent(t -> numberApiFa... | @Test public void generateBookNumber() throws Exception { final Response response = webTarget.path("book").request().get(); assertEquals(OK.getStatusCode(), response.getStatus()); assertTrue(response.readEntity(String.class).startsWith("BK-")); } |
BookResource { @GET @Path("/{id : \\d+}") @Produces(APPLICATION_JSON) @ApiOperation(value = "Find a Book by the Id.", response = Book.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Book found"), @ApiResponse(code = 400, message = "Invalid input"), @ApiResponse(code = 404, message = "Book not found")... | @Test @InSequence(1) public void findById() throws Exception { final Response response = webTarget.path("{id}").resolveTemplate("id", 0).request().get(); assertEquals(OK.getStatusCode(), response.getStatus()); } |
BookResource { @GET @Produces(APPLICATION_JSON) @ApiOperation(value = "Find all Books", response = Book.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "All books found"), @ApiResponse(code = 404, message = "Books not found")} ) public Response findAll() { log.info("Getting... | @Test @InSequence(2) public void findAll() throws Exception { final Response response = webTarget.request().get(); assertEquals(OK.getStatusCode(), response.getStatus()); } |
BookResource { @POST @Consumes(APPLICATION_JSON) @ApiOperation(value = "Create a Book") @ApiResponses(value = { @ApiResponse(code = 201, message = "The book is created"), @ApiResponse(code = 400, message = "Invalid input"), @ApiResponse(code = 415, message = "Format is not JSon") }) public Response create(@ApiParam(val... | @Test @InSequence(3) public void create() throws Exception { final Book book = new Book("Joshua Bloch", "Effective Java (2nd Edition)", 2001, "Tech", " 978-0-3213-5668-0"); final Response response = webTarget.request().post(entity(book, APPLICATION_JSON_TYPE)); assertEquals(CREATED.getStatusCode(), response.getStatus()... |
BookResource { @PUT @Path("/{id : \\d+}") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Update a Book", response = Book.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "The book is updated"), @ApiResponse(code = 400, message = "Invalid input") }) public Response update... | @Test @InSequence(4) public void update() throws Exception { final Book book = new Book("Joshua Bloch", "Effective Java (3rd Edition)", 2018, "Tech", " 978-0-1346-8599-1"); final Response response = webTarget.path("{id}") .resolveTemplate("id", 1) .request() .put(entity(book, APPLICATION_JSON_TYPE)); assertEquals(OK.ge... |
BookResource { @DELETE @Path("/{id : \\d+}") @ApiOperation(value = "Delete a Book") @ApiResponses(value = { @ApiResponse(code = 204, message = "Book has been deleted"), @ApiResponse(code = 400, message = "Invalid input") }) public Response delete(@PathParam("id") final Long id) { log.info("Deleting the book " + id); bo... | @Test @InSequence(5) public void delete() throws Exception { final Response response = webTarget.path("{id}") .resolveTemplate("id", 1) .request() .delete(); assertEquals(NO_CONTENT.getStatusCode(), response.getStatus()); } |
NumberResource { @GET @Path("book") @ApiOperation(value = "Generates a book number.", response = String.class) public Response generateBookNumber() { log.info("Generating a book number"); return Response.ok("BK-" + Math.random()).build(); } @GET @Path("book") @ApiOperation(value = "Generates a book number.", response ... | @Test public void generateBookNumber() throws Exception { final Response response = webTarget.path("book").request().get(); assertEquals(OK.getStatusCode(), response.getStatus()); assertTrue(response.readEntity(String.class).startsWith("BK-")); } |
BookResource { @GET @Produces(APPLICATION_JSON) @ApiOperation(value = "Find all Books", response = Book.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "All books found"), @ApiResponse(code = 404, message = "Books not found")} ) public Response findAll() { log.info("Getting... | @Test @InSequence(2) public void findAll() throws Exception { final Response response = webTarget.request().get(); assertEquals(OK.getStatusCode(), response.getStatus()); } |
NumberResource { @GET @Path("book") @ApiOperation(value = "Generates a book number.", response = String.class) public Response generateBookNumber() throws InterruptedException { final Config config = ConfigProvider.getConfig(); config.getOptionalValue("NUMBER_API_FAKE_TIMEOUT", Integer.class).ifPresent(t -> numberApiFa... | @Test public void generateBookNumber() throws Exception { final Response response = webTarget.path("book").request().get(); assertEquals(OK.getStatusCode(), response.getStatus()); assertTrue(response.readEntity(String.class).startsWith("BK-")); } |
BookResource { @POST @Consumes(APPLICATION_JSON) @ApiOperation(value = "Create a Book") @ApiResponses(value = { @ApiResponse(code = 201, message = "The book is created"), @ApiResponse(code = 400, message = "Invalid input"), @ApiResponse(code = 415, message = "Format is not JSon") }) public Response create(@ApiParam(val... | @Test @InSequence(3) public void create() throws Exception { final Book book = new Book("Joshua Bloch", "Effective Java (2nd Edition)", 2001, "Tech", " 978-0-3213-5668-0"); final Response response = webTarget.request().post(entity(book, APPLICATION_JSON_TYPE)); assertEquals(CREATED.getStatusCode(), response.getStatus()... |
BookResource { @GET @Path("/{id : \\d+}") @Produces(APPLICATION_JSON) @ApiOperation(value = "Find a Book by the Id.", response = Book.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Book found"), @ApiResponse(code = 400, message = "Invalid input"), @ApiResponse(code = 404, message = "Book not found")... | @Test @InSequence(1) public void findById() throws Exception { final Response response = webTarget.path("{id}").resolveTemplate("id", 0).request().get(); assertEquals(OK.getStatusCode(), response.getStatus()); } |
BookResource { @GET @Produces(APPLICATION_JSON) @ApiOperation(value = "Find all Books", response = Book.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "All books found"), @ApiResponse(code = 404, message = "Books not found")} ) public Response findAll() { log.info("Getting... | @Test @InSequence(2) public void findAll() throws Exception { final Response response = webTarget.request().get(); assertEquals(OK.getStatusCode(), response.getStatus()); } |
BookResource { @POST @Consumes(APPLICATION_JSON) @ApiOperation(value = "Create a Book") @ApiResponses(value = { @ApiResponse(code = 201, message = "The book is created"), @ApiResponse(code = 400, message = "Invalid input"), @ApiResponse(code = 415, message = "Format is not JSon") }) public Response create(@ApiParam(val... | @Test @InSequence(3) public void create() throws Exception { final Book book = new Book("Joshua Bloch", "Effective Java (2nd Edition)", 2001, "Tech", " 978-0-3213-5668-0"); final Response response = webTarget.request().post(entity(book, APPLICATION_JSON_TYPE)); assertEquals(CREATED.getStatusCode(), response.getStatus()... |
BookResource { @PUT @Path("/{id : \\d+}") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Update a Book", response = Book.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "The book is updated"), @ApiResponse(code = 400, message = "Invalid input") }) public Response update... | @Test @InSequence(4) public void update() throws Exception { final Book book = new Book("Joshua Bloch", "Effective Java (3rd Edition)", 2018, "Tech", " 978-0-1346-8599-1"); final Response response = webTarget.path("{id}") .resolveTemplate("id", 1) .request() .put(entity(book, APPLICATION_JSON_TYPE)); assertEquals(OK.ge... |
BookResource { @PUT @Path("/{id : \\d+}") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Update a Book", response = Book.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "The book is updated"), @ApiResponse(code = 400, message = "Invalid input") }) public Response update... | @Test @InSequence(4) public void update() throws Exception { final Book book = new Book("Joshua Bloch", "Effective Java (3rd Edition)", 2018, "Tech", " 978-0-1346-8599-1"); final Response response = webTarget.path("{id}") .resolveTemplate("id", 1) .request() .put(entity(book, APPLICATION_JSON_TYPE)); assertEquals(OK.ge... |
BookResource { @DELETE @Path("/{id : \\d+}") @ApiOperation(value = "Delete a Book") @ApiResponses(value = { @ApiResponse(code = 204, message = "Book has been deleted"), @ApiResponse(code = 400, message = "Invalid input") }) public Response delete(@PathParam("id") final Long id) { log.info("Deleting the book " + id); bo... | @Test @InSequence(5) public void delete() throws Exception { final Response response = webTarget.path("{id}") .resolveTemplate("id", 1) .request() .delete(); assertEquals(NO_CONTENT.getStatusCode(), response.getStatus()); } |
NumberResource { @GET @Path("book") @ApiOperation(value = "Generates a book number.", response = String.class) public Response generateBookNumber() { log.info("Generating a book number"); return Response.ok("BK-" + Math.random()).build(); } @GET @Path("book") // tag::adocSwagger[] @ApiOperation(value = "Generates a bo... | @Test public void generateBookNumber() throws Exception { final Response response = webTarget.path("book").request().get(); assertEquals(OK.getStatusCode(), response.getStatus()); assertTrue(response.readEntity(String.class).startsWith("BK-")); } |
BookResource { @GET @Path("/{id : \\d+}") @Produces(APPLICATION_JSON) @ApiOperation(value = "Find a Book by the Id.", response = Book.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Book found"), @ApiResponse(code = 400, message = "Invalid input"), @ApiResponse(code = 404, message = "Book not found")... | @Test @InSequence(1) public void findById() throws Exception { final Response response = webTarget.path("{id}").resolveTemplate("id", 0).request().get(); assertEquals(OK.getStatusCode(), response.getStatus()); } |
BookResource { @DELETE @Path("/{id : \\d+}") @ApiOperation(value = "Delete a Book") @ApiResponses(value = { @ApiResponse(code = 204, message = "Book has been deleted"), @ApiResponse(code = 400, message = "Invalid input") }) public Response delete(@PathParam("id") final Long id) { log.info("Deleting the book " + id); bo... | @Test @InSequence(5) public void delete() throws Exception { final Response response = webTarget.path("{id}") .resolveTemplate("id", 1) .request() .delete(); assertEquals(NO_CONTENT.getStatusCode(), response.getStatus()); } |
NumberResource { @GET @Path("book") @ApiOperation(value = "Generates a book number.", response = String.class) public Response generateBookNumber() { log.info("Generating a book number"); return Response.ok("BK-" + Math.random()).build(); } @GET @Path("book") @ApiOperation(value = "Generates a book number.", response ... | @Test public void generateBookNumber() throws Exception { final Response response = webTarget.path("book").request().get(); assertEquals(OK.getStatusCode(), response.getStatus()); assertTrue(response.readEntity(String.class).startsWith("BK-")); } |
BookResource { @GET @Path("/{id : \\d+}") @Produces(APPLICATION_JSON) @ApiOperation(value = "Find a Book by the Id.", response = Book.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Book found"), @ApiResponse(code = 400, message = "Invalid input"), @ApiResponse(code = 404, message = "Book not found")... | @Test @InSequence(1) public void findById() throws Exception { final Response response = webTarget.path("{id}").resolveTemplate("id", 0).request().get(); assertEquals(OK.getStatusCode(), response.getStatus()); } |
BookResource { @GET @Produces(APPLICATION_JSON) @ApiOperation(value = "Find all Books", response = Book.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "All books found"), @ApiResponse(code = 404, message = "Books not found")} ) public Response findAll() { log.info("Getting... | @Test @InSequence(2) public void findAll() throws Exception { final Response response = webTarget.request().get(); assertEquals(OK.getStatusCode(), response.getStatus()); } |
BookResource { @POST @Consumes(APPLICATION_JSON) @ApiOperation(value = "Create a Book") @ApiResponses(value = { @ApiResponse(code = 201, message = "The book is created"), @ApiResponse(code = 400, message = "Invalid input"), @ApiResponse(code = 415, message = "Format is not JSon") }) public Response create(@ApiParam(val... | @Test @InSequence(3) public void create() throws Exception { final Book book = new Book("Joshua Bloch", "Effective Java (2nd Edition)", 2001, "Tech", " 978-0-3213-5668-0"); final Response response = webTarget.request().post(entity(book, APPLICATION_JSON_TYPE)); assertEquals(CREATED.getStatusCode(), response.getStatus()... |
BookResource { @PUT @Path("/{id : \\d+}") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Update a Book", response = Book.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "The book is updated"), @ApiResponse(code = 400, message = "Invalid input") }) public Response update... | @Test @InSequence(4) public void update() throws Exception { final Book book = new Book("Joshua Bloch", "Effective Java (3rd Edition)", 2018, "Tech", " 978-0-1346-8599-1"); final Response response = webTarget.path("{id}") .resolveTemplate("id", 1) .request() .put(entity(book, APPLICATION_JSON_TYPE)); assertEquals(OK.ge... |
AlbumService implements PaginatedService { public ResourceDto<AlbumDto> getAlbumsPage() { return getAlbumsPage(FIRST_PAGE_NUM); } @Inject AlbumService(@Named("albumDao") AlbumDao albumDao, @Named("artistDao") MaprDbDao<Artist> artistDao,
LanguageDao languageDao, SlugService slugService, Statist... | @Test public void getNegativePageTest() { thrown.expect(IllegalArgumentException.class); AlbumDao albumDao = mock(AlbumDao.class); LanguageDao languageDao = mock(LanguageDao.class); SlugService slugService = mock(SlugService.class); StatisticService statisticService = mock(StatisticService.class); MaprDbDao<Artist> art... |
AlbumService implements PaginatedService { public AlbumDto getAlbumById(String id) { if (id == null || id.isEmpty()) { throw new IllegalArgumentException("Album's identifier can not be empty"); } Album album = albumDao.getById(id); if (album == null) { throw new ResourceNotFoundException("Album with id '" + id + "' not... | @Test public void getByNullId() { thrown.expect(IllegalArgumentException.class); AlbumDao albumDao = mock(AlbumDao.class); LanguageDao languageDao = mock(LanguageDao.class); SlugService slugService = mock(SlugService.class); StatisticService statisticService = mock(StatisticService.class); MaprDbDao<Artist> artistDao =... |
SecKillCommandService { public SecKillGrabResult addCouponTo(T customerId) { if (recoveryInfo.getClaimedCustomers().add(customerId)) { if (claimedCoupons.getAndIncrement() < recoveryInfo.remainingCoupons()) { return couponQueue.offer(customerId) ? SecKillGrabResult.Success : SecKillGrabResult.Failed; } return SecKillGr... | @Test public void putsAllCustomersInQueue() { for (int i = 0; i < 5; i++) { SecKillGrabResult success = commandService.addCouponTo(i); assertThat(success, is(SecKillGrabResult.Success)); } assertThat(coupons, contains(0, 1, 2, 3, 4)); }
@Test public void noMoreItemAddedToQueueOnceFull() { keepConsumingCoupons(); int th... |
SecKillRecoveryService { public SecKillRecoveryCheckResult<T> check(PromotionEntity promotion) { List<EventEntity> entities = this.repository.findByPromotionId(promotion.getPromotionId()); if (!entities.isEmpty()) { long count = entities.stream() .filter(event -> SecKillEventType.CouponGrabbedEvent.equals(event.getType... | @Test public void unstartPromotionCheck() { SecKillRecoveryCheckResult<String> result = recoveryService.check(unpublishedPromotion); assertThat(result.isStarted(), is(false)); assertThat(result.isFinished(), is(false)); assertThat(result.remainingCoupons(), is(unpublishedPromotion.getNumberOfCoupons())); assertThat(res... |
SpanTemplate implements SpanOperations { @Override public ActiveSpan startActive(String name) { return tracer.buildSpan(name) .startActive(); } SpanTemplate(Tracer tracer); @Override void doInTracer(SpanCallback callback); @Override Span start(String name); @Override ActiveSpan startActive(String name); @Override Activ... | @Test public void testStartActive() throws InterruptedException { try (ActiveSpan span = spanOps.startActive("hello sematextains")) { span.setTag("app", "console"); } Thread.sleep(2000); }
@Test public void testStartActiveWithParent() throws InterruptedException { try (ActiveSpan parent = spanOps.startActive("parent"))... |
SpanTemplate implements SpanOperations { @Override public void inject(SpanContext ctx, HttpHeaders headers) { HttpHeadersInjectAdapter injectAdapter = new HttpHeadersInjectAdapter(headers); tracer.inject(ctx, Format.Builtin.HTTP_HEADERS, injectAdapter); } SpanTemplate(Tracer tracer); @Override void doInTracer(SpanCallb... | @Test public void testInject() { try (ActiveSpan span = spanOps.startActive("parent")) { Map<String, Object> map = new HashMap<>(); map.put("app", "console"); HttpHeaders headers = new HttpHeaders(); spanOps.inject(span.context(), headers); } } |
StateCapture { public static Executor capturingDecorator(final Executor executor) { if (stateCaptors.isEmpty() || executor instanceof CapturingExecutor) { return executor; } else { return new CapturingExecutor(executor); } } private StateCapture(); static Executor capturingDecorator(final Executor executor); static Ex... | @Test public void testExecutorCaptures() throws InterruptedException { ExecutorService e = Executors.newCachedThreadPool(); Executor f = StateCapture.capturingDecorator(e); CapturedState mockCapturedState = mock(CapturedState.class); Runnable mockRunnable = mock(Runnable.class); ThreadLocalStateCaptor.THREAD_LOCAL.set(... |
MXBeanPoller { public void shutdown() { running.set(false); executor.shutdown(); try { executor.awaitTermination(SHUTDOWN_TIMEOUT, TimeUnit.SECONDS); } catch (InterruptedException e) { executor.shutdownNow(); Thread.currentThread().interrupt(); } } MXBeanPoller(final MetricRecorder metricRecorder,
... | @Test public void shutdown() throws Exception { final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); MXBeanPoller poller = new MXBeanPoller(executor, new NullRecorder(), 5, Collections.emptyList()); poller.shutdown(); assertTrue("Executor not shutdown on poller shutdown", executor.isS... |
FileRecorder extends MetricRecorder<MetricRecorder.RecorderContext> { static boolean isValid(final Metric label) { final String str = label.toString(); return !(str.contains("\n") || str.contains(",") || str.contains(":") || str.contains("=")); } FileRecorder(final String filename); static final FileRecorder withAutoSh... | @Test public void validation() { final String[] good = { "snake_case_metric", "camelCaseMetric", "hyphenated-metric", "spaced out metric", "digits 0123456789", "G\u00FCnther", "\t!\"#$%&'()*+./;<>?@[\\]^`{|}~" }; for (final String s : good) { assertTrue("valid name [" + s + "]", FileRecorder.isValid(Metric.define(s)));... |
DimensionMapper { public List<Dimension> getDimensions(final Metric metric, final MetricRecorder.RecorderContext context) { TypedMap attributes = flattenContextHierarchy(context); Set<TypedMap.Key> dimensionKeys = filterMap.get(metric); if (dimensionKeys == null) { dimensionKeys = Collections.emptySet(); } Stream<Typed... | @Test public void no_mappings() throws Exception { MetricRecorder.RecorderContext context = new MetricRecorder.RecorderContext(ContextData.withId(ID) .add(StandardContext.SERVICE, SERVICE_NAME) .build()); DimensionMapper mapper = new DimensionMapper.Builder().build(); assertTrue("Empty mapping resulted in non-empty dim... |
DoubleFormat { public static void format(Appendable sb, double value) { try { format_exception(sb, value); } catch (IOException e) { throw new IllegalStateException("Appendable must not throw IOException", e); } } private DoubleFormat(); static void format(Appendable sb, double value); } | @Test public void benchmark() throws Exception { final long iterations = 1000000; long duration_StringFormat = run_benchmark(iterations, (a) -> String.format("%.6f", a)); NumberFormat javaFormatter = NumberFormat.getInstance(); javaFormatter.setMinimumFractionDigits(0); javaFormatter.setMaximumFractionDigits(6); javaFo... |
ContextAwareExecutor implements Executor { @Override public void execute(Runnable command) { executor.execute(ThreadContext.current().wrap(command)); } ContextAwareExecutor(Executor executor); @Override void execute(Runnable command); } | @Test public void currentContextIsPropagatedToTask() throws Exception { ThreadContext context = ThreadContext.emptyContext().with(KEY, "value"); try (ThreadContext.CloseableContext ignored = context.open()) { executor.execute(captureTask); } latch.await(); assertSame(context, contextCapture.get()); }
@Test public void ... |
ImmutableTypedMap implements TypedMap { @Override public Set<Key> keySet() { return this.dataMap.keySet(); } private ImmutableTypedMap(Map<Key<?>, Entry<?>> dataMap); @Override final T get(Key<T> key); @Override int size(); @Override boolean isEmpty(); @Override Iterator<Entry> iterator(); @Override Iterator<Entry<T>>... | @Test public void keyset() throws Exception { final TypedMap.Key<Double> ka = TypedMap.key("Alpha", Double.class); final TypedMap.Key<String> kb = TypedMap.key("Beta", String.class); final TypedMap.Key<UUID> kc = TypedMap.key("Gamma", UUID.class); final TypedMap.Key<Object> kd = TypedMap.key("Delta", Object.class); fin... |
ImmutableTypedMap implements TypedMap { @Override public <T> Set<Key<T>> typedKeySet(final Class<T> clazz) { Set<Key<T>> keys = new HashSet<>(); for (Key k : this.keySet()) { if (k.valueType.equals(clazz)) { keys.add(k); } } return Collections.unmodifiableSet(keys); } private ImmutableTypedMap(Map<Key<?>, Entry<?>> da... | @Test public void typedKeyset() throws Exception { final TypedMap.Key<Double> ka = TypedMap.key("A", Double.class); final TypedMap.Key<String> kb = TypedMap.key("B", String.class); final TypedMap.Key<String> kc = TypedMap.key("C", String.class); final TypedMap.Key<Object> kd = TypedMap.key("D", Object.class); final Dou... |
ImmutableTypedMap implements TypedMap { @Override public Iterator<Entry> iterator() { return this.dataMap.values().iterator(); } private ImmutableTypedMap(Map<Key<?>, Entry<?>> dataMap); @Override final T get(Key<T> key); @Override int size(); @Override boolean isEmpty(); @Override Iterator<Entry> iterator(); @Overrid... | @Test public void iterator() throws Exception { final TypedMap.Key<Long> ka = TypedMap.key("1", Long.class); final TypedMap.Key<Short> kb = TypedMap.key("2", Short.class); final TypedMap.Key<BigInteger> kc = TypedMap.key("5", BigInteger.class); final Long va = Long.valueOf(999999999); final Short vb = Short.valueOf((sh... |
ImmutableTypedMap implements TypedMap { @Override public int size() { return this.dataMap.size(); } private ImmutableTypedMap(Map<Key<?>, Entry<?>> dataMap); @Override final T get(Key<T> key); @Override int size(); @Override boolean isEmpty(); @Override Iterator<Entry> iterator(); @Override Iterator<Entry<T>> typedIte... | @Test public void forEach() throws Exception { final TypedMap.Key<Long> ka = TypedMap.key("1", Long.class); final TypedMap.Key<Short> kb = TypedMap.key("2", Short.class); final TypedMap.Key<BigInteger> kc = TypedMap.key("5", BigInteger.class); final Long va = Long.valueOf(999999999); final Short vb = Short.valueOf((sho... |
ImmutableTypedMap implements TypedMap { @Override public <T> Iterator<Entry<T>> typedIterator(Class<T> clazz) { List<Entry<T>> entries = new ArrayList(); for (Iterator<Entry> it = this.iterator(); it.hasNext(); ) { final Entry e = it.next(); if (e.getKey().valueType.equals(clazz)) { entries.add(e); } } return Collectio... | @Test public void typedIterator() throws Exception { final TypedMap.Key<String> ka = TypedMap.key("y", String.class); final TypedMap.Key<Object> kb = TypedMap.key("n", Object.class); final TypedMap.Key<String> kc = TypedMap.key("m", String.class); final String va = "yes"; final String vb = "no"; final String vc = "mayb... |
NullContext implements MetricContext { @Override public TypedMap attributes() { return attributes; } NullContext(TypedMap attributes); NullContext(TypedMap attributes, MetricContext parent); static NullContext empty(); @Override TypedMap attributes(); @Override void record(Metric label, Number value, Unit unit, Insta... | @Test public void nullContextCanHaveAttributes() { TypedMap.Key<String> ID = TypedMap.key("ID", String.class); TypedMap attributes = ImmutableTypedMap.Builder.with(ID, "id").build(); NullContext context = new NullContext(attributes); assertSame(attributes, context.attributes()); } |
Metric { public static Metric define(final String name) { return new Metric(name); } private Metric(final String name); static Metric define(final String name); @Override final String toString(); @Override boolean equals(final Object o); @Override int hashCode(); } | @Test public void validation() throws Exception { final String[] goods = { "snake_case_metric", "camelCaseMetric", "hyphenated-metric", "spaced out metric", "digits 0123456789", "G\u00FCnther", "\t\n!\"#$%&'()*+,./:;<=>?@[\\]^`{|}~", " " }; for (String s : goods) { Metric.define(s); } final String[] bads = { null, "" }... |
MultiRecorder extends MetricRecorder<MultiRecorder.MultiRecorderContext> { @Override protected void record(Metric label, Number value, Unit unit, Instant time, MultiRecorderContext context) { context.contexts.parallelStream().forEach(t -> t.record(label, value, unit, time)); } MultiRecorder(List<MetricRecorder<?>> reco... | @Test public void recordIsSentToAllDelegates() { MetricContext context = recorder.context(attributes); context.record(METRIC, 42L, Unit.NONE, timestamp); verify(delegate1).record(eq(METRIC), eq(42L), eq(Unit.NONE), eq(timestamp), argThat(t -> attributes == t.attributes())); verify(delegate2).record(eq(METRIC), eq(42L),... |
MultiRecorder extends MetricRecorder<MultiRecorder.MultiRecorderContext> { @Override protected void count(Metric label, long delta, MultiRecorderContext context) { context.contexts.parallelStream().forEach(t -> t.count(label, delta)); } MultiRecorder(List<MetricRecorder<?>> recorders); } | @Test public void countIsSentToAllDelegates() { MetricContext context = recorder.context(attributes); context.count(METRIC, 42L); verify(delegate1).count(eq(METRIC), eq(42L), argThat(t -> attributes == t.attributes())); verify(delegate2).count(eq(METRIC), eq(42L), argThat(t -> attributes == t.attributes())); } |
MultiRecorder extends MetricRecorder<MultiRecorder.MultiRecorderContext> { @Override protected void close(MultiRecorderContext context) { context.contexts.parallelStream().forEach(MetricContext::close); } MultiRecorder(List<MetricRecorder<?>> recorders); } | @Test public void closeIsSentToAllDelegates() { MetricContext context = recorder.context(attributes); context.close(); verify(delegate1).close(argThat(t -> attributes == t.attributes())); verify(delegate2).close(argThat(t -> attributes == t.attributes())); } |
DocHighlighter { protected void highlightSingleFieldValue(String field, String s, Set<HighlightingQuery> highlightingQueries, Analyzer analyzer, AtomicBoolean anythingHighlighted, RhapsodeXHTMLHandler xhtml) throws IOException, SAXException { if (highlightingQueries == null || highlightingQueries.size() == 0) { xhtml.c... | @Test public void testBasic() throws IOException, SAXException { String s = "the quick brown fox as well as some other fox and quick"; SpanQuery spanQuery = new SpanOrQuery(foxQuick, foxAs, new SpanTermQuery(new Term(field, "fox"))); Analyzer analyzer = new WhitespaceAnalyzer(); ContentHandler handler = new ToHTMLConte... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.