@Test public void noIndexPreviouslyDefinedInQueryService() throws Exception { when(queryService.createDefinedIndexes()).thenReturn(Collections.emptyList()); context = new FunctionContextImpl(cache, CreateDefinedIndexesFunction.class.getName(), indexDefinitions, resultSender); function.execute(context); List<?> results = resultSender.getResults(); assertThat(results).isNotNull(); assertThat(results.size()).isEqualTo(2); Object firstResult = results.get(0); assertThat(firstResult).isInstanceOf(CliFunctionResult.class); assertThat(((CliFunctionResult) firstResult).isSuccessful()).isTrue(); assertThat(((CliFunctionResult) firstResult).getMessage()).isNotEmpty(); assertThat(((CliFunctionResult) firstResult).getMessage()).contains("No indexes defined"); }
@Test public void noIndexDefinitionsAsFunctionArgument() throws Exception { context = new FunctionContextImpl(cache, CreateDefinedIndexesFunction.class.getName(), Collections.emptySet(), resultSender); function.execute(context); List<?> results = resultSender.getResults(); assertThat(results).isNotNull(); assertThat(results.size()).isEqualTo(2); Object firstResult = results.get(0); assertThat(firstResult).isInstanceOf(CliFunctionResult.class); assertThat(((CliFunctionResult) firstResult).isSuccessful()).isTrue(); assertThat(((CliFunctionResult) firstResult).getMessage()).isNotEmpty(); assertThat(((CliFunctionResult) firstResult).getMessage()).contains("No indexes defined"); }
@Test public void findByUsernameWhenClearCredentialsThenFindByUsernameStillHasCredentials() { User foundUser = users.findByUsername(USER_DETAILS.getUsername()).cast(User.class).block(); assertThat(foundUser.getPassword()).isNotEmpty(); foundUser.eraseCredentials(); assertThat(foundUser.getPassword()).isNull(); foundUser = users.findByUsername(USER_DETAILS.getUsername()).cast(User.class).block(); assertThat(foundUser.getPassword()).isNotEmpty(); }
@Test public void infoResultDataStructure() { InfoResultData result = ResultBuilder.createInfoResultData(); result.addLine("line 1"); result.addLine("line 2"); result.setHeader("Heads"); result.setFooter("Tails"); CommandResult cmdResult = ResultBuilder.buildResult(result); assertThat(cmdResult.getHeader()).isEqualTo("Heads"); assertThat(cmdResult.getListFromContent("message")).contains("line 1", "line 2"); assertThat(cmdResult.getFooter()).isEqualTo("Tails"); assertThat(cmdResult.getValueFromContent("message")).isNotEmpty(); assertThat(cmdResult.getStatus()).isEqualTo(Result.Status.OK); }
@Test public void errorResultDataStructure() { ErrorResultData result = ResultBuilder.createErrorResultData(); result.addLine("line 1"); result.addLine("line 2"); result.setHeader("Heads"); result.setFooter("Tails"); CommandResult cmdResult = ResultBuilder.buildResult(result); assertThat(cmdResult.getHeader()).isEqualTo("Heads"); assertThat(cmdResult.getListFromContent("message")).contains("line 1", "line 2"); assertThat(cmdResult.getFooter()).isEqualTo("Tails"); assertThat(cmdResult.getValueFromContent("message")).isNotEmpty(); assertThat(cmdResult.getStatus()).isEqualTo(Result.Status.ERROR); }
@Override public void tearDown() throws Exception { try { Optional<Span> finishedSpan = Tracer.completeSpan(); SpanObserver observer = Tracer.unsubscribe(TEST_OBSERVER_NAME); assertThat(observer).isInstanceOf(TestSpanObserver.class); List<Span> spans = ((TestSpanObserver) observer).spans(); log.warn("{} spans: {}", spans.size(), spans.stream().map(Span::getOperation).collect(Collectors.toList())); if (Tracer.isTraceObservable()) { assertThat(finishedSpan.isPresent()).isTrue(); assertThat(finishedSpan.get().getOperation()).isEqualTo("test"); String traceId = finishedSpan.get().getTraceId(); assertThat(traceId).isNotNull(); assertThat(traceId).isNotEmpty(); assertThat(spans).isNotEmpty(); assertThat(spans.size()) .describedAs("Should include root test span and additional KVS method spans %s", spans) .isGreaterThanOrEqualTo(1); assertThat(spans.stream() .filter(span -> !Objects.equals(traceId, span.getTraceId())) .map(Span::getTraceId) .collect(Collectors.toSet())) .describedAs("All spans should have same trace ID %s, spans %s", traceId, spans) .isEmpty(); } } finally { super.tearDown(); } }
public AssertFileContent isFile() { assertThat(response).isNotNull(); assertThat(response.getContentType()).isNotNull(); assertThat(response.getContentAsByteArray()).isNotEmpty(); assertThat(response.getHeader(CONTENT_DISPOSITION)) .isNotEmpty() .startsWith(ATTACHMENT_CONTENT_DISPOSITION); String filename = response.getHeader(CONTENT_DISPOSITION) .substring(ATTACHMENT_CONTENT_DISPOSITION.length()); return new AssertFileContent(new FileContent(filename, response.getContentType(), response.getContentAsByteArray())); }
@Test void responseContent() { final Collection<NameValuePair> nvp = Collections.singletonList(new BasicNameValuePair("key", "value")); final HttpEntity e = new UrlEncodedFormEntity(nvp); assertThat(Util.readEntity(e)).isNotEmpty(); } }
@Test public void sendTransactionTest() { String res = txApiImpl.sendTransaction(TransactionDto.createBy(tx)); assertThat(res).isNotEmpty(); }
@ParameterizedTest @MethodSource("describe") void describe(final AbstractFeature feature) { assertThat(feature.describe()).isNotEmpty(); }
@Test void hasRichCode() { for (final Region r: Region.values()) { assertThat(r.getRichCode()).isNotEmpty(); } }
private static <T extends Event> void testFormal(final AbstractListener<T> listener, final T event, final SupportedListener listenerType) { assertThat(event).isInstanceOf(listenerType.getEventType()); assertThat(listener.getTemplateFileName()) .isNotNull() .isNotEmpty(); }
@Test public void sendTransactionTest() { TransactionHusk tx = createTx(); // Request Transaction with jsonStr try { assertThat(TX_API.sendTransaction(TransactionDto.createBy(tx))).isNotEmpty(); } catch (Exception exception) { log.debug("\n\nsendTransactionTest :: exception => " + exception); } }
@Test public void testToString() { assertThat(Entry.ofText(new Revision(1), "/a.txt", "a").toString()).isNotEmpty(); } }
@Test public void initTest() { assertThat(stateValue.getType()).isNull(); assertThat(stateValue.getTag()).isNull(); assertThat(stateValue.getContractHistory()).isEmpty(); stateValue.init(); assertThat(stateValue.getType()).isEqualTo(Branch.BranchType.TEST); assertThat(stateValue.getTag()).isNotEmpty(); assertThat(stateValue.getContractHistory()).contains(stateValue.getContractId()); }
@Test @DisplayName("should cache loaded sha") void shouldCache() { RedisScriptLoader scriptLoader = new RedisScriptLoader(extension.getScriptingReactiveCommands(), "hello-world.lua"); assertThat(scriptLoader.storedScript().block(Duration.ofSeconds(5)).getSha()).isNotEmpty(); scriptFlush(); assertThat(scriptLoader.storedScript().block(Duration.ofSeconds(5)).getSha()).isNotEmpty(); }
@Test public void testStore() throws Exception { final KeyStoreHelper helper = new KeyStoreHelper(CertificateUtilTest.TEST_CERT, "test-cert"); helper.store(); assertThat(helper.getKeyStorePath()).isNotEmpty(); assertThat(helper.getPassword()).isNotEmpty(); }
@Test public void shouldFetchFromStaticResource() throws Exception { final String json = new StaticResourceClassInspector(new DefaultResourceLoader()).fetchJsonFor("twitter4j.Status", null); assertThat(json).isNotEmpty(); } }
@Test @DisplayName("should load rate limit lua script into Redis") void shouldLoadScript() { RedisScriptLoader scriptLoader = new RedisScriptLoader(extension.getScriptingReactiveCommands(), "hello-world.lua"); scriptFlush(); String sha = scriptLoader.storedScript().block(Duration.ofSeconds(5)).getSha(); assertThat(sha).isNotEmpty(); assertThat(extension.getScriptingReactiveCommands().scriptExists(sha).blockFirst()).isTrue(); }
@Test @DisplayName("should eagerly load rate limit lua script into Redis") void shouldEagerlyLoadScript() { RedisScriptLoader scriptLoader = new RedisScriptLoader(extension.getScriptingReactiveCommands(), "hello-world.lua", true); String sha = scriptLoader.storedScript().block(Duration.ofSeconds(5)).getSha(); assertThat(sha).isNotEmpty(); scriptFlush(); new RedisScriptLoader(extension.getScriptingReactiveCommands(), "hello-world.lua", true); assertThat(extension.getScriptingReactiveCommands().scriptExists(sha).blockFirst()).isTrue(); }