private void verifyOpenCommMsgBeakerxWidget(List<Message> messages, String modelNameValue, String viewNameValue) { assertThat(messages.size()).isEqualTo(1); Message widget = messages.get(0); assertThat(widget.getHeader().getType()).isEqualTo(COMM_OPEN.getName()); Map data = TestWidgetUtils.getData(widget); assertThat(data.get(Widget.MODEL_MODULE)).isEqualTo(BeakerxWidget.MODEL_MODULE_VALUE); assertThat(data.get(Widget.VIEW_MODULE)).isEqualTo(BeakerxWidget.VIEW_MODULE_VALUE); assertThat(data.get(Widget.MODEL_NAME)).isEqualTo(modelNameValue); assertThat(data.get(Widget.VIEW_NAME)).isEqualTo(viewNameValue); }
private void verifyJob(long wait, TimeUnit timeUnit) throws InterruptedException { assertThat(mJob.mLatch.await(wait, timeUnit)).isTrue(); assertThat(mContext).isInstanceOf(mExpectedContext); Bundle extras = mParams.getTransientExtras(); assertThat(extras).isNotNull(); } }
@Test public void resourceNameTest() throws IOException{ JarFile guavaFile = new JarFile(FilePathUtil.getJarPath(Files.class)); assertThat(guavaFile.getEntry("META-INF/MANIFEST.MF")).isNotNull(); assertThat(guavaFile.getEntry("/META-INF/MANIFEST.MF")).isNull(); guavaFile.close(); }
@Test public void loadFactoryOrNull() throws Exception { NotImplementedSPI factory = ServiceHelper.loadFactoryOrNull(NotImplementedSPI.class); assertThat(factory).isNull(); FakeFactory fake = ServiceHelper.loadFactoryOrNull(FakeFactory.class); assertThat(fake).isNotNull(); assertThat(fake.classloader()).isEqualTo(ServiceHelperTest.class.getClassLoader()); }
private static void assertMergeHiveColumnStatistics(HiveColumnStatistics first, HiveColumnStatistics second, HiveColumnStatistics expected) { assertThat(merge(first, second)).isEqualTo(expected); assertThat(merge(second, first)).isEqualTo(expected); } }
@Test public void canBuildRetryFromRegistryWithConfigSupplier() { RetryConfig config = RetryConfig.custom().maxAttempts(1000).waitDuration(Duration.ofSeconds(300)).build(); AsyncRetry retry = retryRegistry.retry("testName", () -> config); Assertions.assertThat(retry).isNotNull(); Assertions.assertThat(retryRegistry.getAllRetries()).hasSize(1); }
@Test public void shouldSendCommMsgWhenDoubleClickActionChange() throws Exception { //given //when tableDisplay.setDoubleClickAction(new Object()); //then assertThat(tableDisplay.hasDoubleClickAction()).isEqualTo(true); LinkedHashMap model = getModelUpdate(); assertThat(model.size()).isEqualTo(2); assertThat(model.get(HAS_DOUBLE_CLICK_ACTION)).isEqualTo(true); }
@Test public void parsePlotWithTextScript_returnPlotObjectWithText() { //when Object result = parseClassFromScript("def plot = new Plot ()\n" + "plot << new Text(text: \"labelText \")"); //then Assertions.assertThat(result instanceof Plot).isTrue(); Plot plot = (Plot) result; Assertions.assertThat(plot.getTexts()).isNotEmpty(); Assertions.assertThat(plot.getTexts().get(0)).isNotNull(); }
@Test public void general() { List<String> list1 = ListUtil.newArrayList(); List<String> list2 = ListUtil.newArrayList("a", "b", "c"); List<String> list3 = ListUtil.newArrayList("a"); assertThat(ListUtil.isEmpty(list1)).isTrue(); assertThat(ListUtil.isEmpty(null)).isTrue(); assertThat(ListUtil.isEmpty(list2)).isFalse(); assertThat(ListUtil.isNotEmpty(list1)).isFalse(); assertThat(ListUtil.isNotEmpty(null)).isFalse(); assertThat(ListUtil.isNotEmpty(list2)).isTrue(); assertThat(ListUtil.getFirst(list2)).isEqualTo("a"); assertThat(ListUtil.getLast(list2)).isEqualTo("c"); assertThat(ListUtil.getFirst(list3)).isEqualTo("a"); assertThat(ListUtil.getLast(list3)).isEqualTo("a"); assertThat(ListUtil.getFirst(list1)).isNull(); assertThat(ListUtil.getFirst(null)).isNull(); }
@Test public void commOpen_shouldSendIOPubSocketMessage() throws NoSuchAlgorithmException { //when comm.open(); //then assertThat(kernel.getPublishedMessages()).isNotEmpty(); assertThat(kernel.getPublishedMessages().get(0)).isNotNull(); }
@Test public void setDataWithListOfIntegerListsParam_hasListDataIsNotEmpty() { //given histogram = createWidget(); //when histogram.setData(asList(list1, list2)); //then assertThat(histogram.getListData()).isNotEmpty(); LinkedHashMap model = getModelUpdate(); assertThat(model.size()).isEqualTo(1); assertThat(model.get(GRAPHICS_LIST)).isNotNull(); }
@Test public void testInvokeToString() throws Throwable { final Method toStringMethod = testService.getClass().getMethod("toString"); final Object result = testSubject.invoke(testService, toStringMethod, new Object[0]); verify(methodHandler, times(0)).invoke(any()); assertThat(feignDecorator.isCalled()) .describedAs("FeignDecorator is called") .isTrue(); assertThat(result) .describedAs("Return of invocation") .isEqualTo(target.toString()); }
public void assertThatVertxInstanceHasBeenCreated() { assertThat(getVertx()).isNotNull(); }
@Test public void shouldReturnTheCorrectName() { Retry retry = retryRegistry.retry("testName"); Assertions.assertThat(retry).isNotNull(); Assertions.assertThat(retry.getName()).isEqualTo("testName"); }
@Test public void setColorWithAwtColorParam_colorHasBeakerColorType() { //given histogram = createWidget(); //when histogram.setColor(java.awt.Color.GREEN); //then assertThat(histogram.getColor() instanceof Color).isTrue(); LinkedHashMap model = getModelUpdate(); assertThat(model.size()).isEqualTo(1); assertThat(model.get(COLOR)).isNotNull(); }
@Test public void structuredUpdate_intProgressHasDescriptionAndValue() throws Exception { //when progress.structuredUpdate("msg", 5); //then Assertions.assertThat(progress.getIntProgress()).isNotNull(); Assertions.assertThat(progress.getIntProgress().getDescription()).isEqualTo("msg"); Assertions.assertThat(progress.getIntProgress().getValue()).isEqualTo(5); }
@Test public void appendErrorWithDoubleMaxSizeString_outputDataHasTwoLines() throws Exception { //when seo.appendError("test\n" + generateDoubleMaxSizeString()); //then Assertions.assertThat(seo.getOutputdata().get(0)) .isInstanceOf(SimpleEvaluationObject.EvaluationStdError.class); SimpleEvaluationObject.EvaluationStdError stdErr = (SimpleEvaluationObject.EvaluationStdError) seo.getOutputdata().get(0); Assertions.assertThat(stdErr.payload.split("\n").length).isEqualTo(2); }
@Test public void shouldReturnFailureWithRuntimeException() { // Given BulkheadConfig config = BulkheadConfig.custom().maxConcurrentCalls(2).build(); Bulkhead bulkhead = Bulkhead.of("test", config); bulkhead.isCallPermitted(); //v When CheckedRunnable checkedRunnable = Bulkhead.decorateCheckedRunnable(bulkhead, () -> {throw new RuntimeException("BAM!");}); Try result = Try.run(checkedRunnable); //Then assertThat(result.isFailure()).isTrue(); assertThat(result.failed().get()).isInstanceOf(RuntimeException.class); assertThat(bulkhead.getMetrics().getAvailableConcurrentCalls()).isEqualTo(1); }
@Test public void path() { String json = "{\"a\":[{\"b\":1,\"c\":2},{\"b\":5,\"c\":2}]}"; List<Object> result = JsonPath.using(Configuration.defaultConfiguration().setOptions(Option.DEFAULT_PATH_LEAF_TO_NULL)).parse(json).read("a[?(@.b==5)].d"); Assertions.assertThat(result).hasSize(1); Assertions.assertThat(result.get(0)).isNull(); }
@Test public void shouldSendCommMsgWhenNamesChange() { //given histogram = createWidget(); //when histogram.setNames(asList("name123")); //then assertThat(histogram.getNames()).isEqualTo(asList("name123")); LinkedHashMap model = getModelUpdate(); assertThat(model.size()).isEqualTo(1); assertThat(model.get(HistogramSerializer.NAMES)).isNotNull(); }