@Test public void shouldUseCustomPrefix() { //Given AsyncRetryRegistry retryRegistry = AsyncRetryRegistry.ofDefaults(); AsyncRetry retry = retryRegistry.retry("testName"); metricRegistry.registerAll(AsyncRetryMetrics.ofAsyncRetryRegistry("testPrefix",retryRegistry)); // Given the HelloWorldService returns Hello world BDDMockito.given(helloWorldService.returnHelloWorld()).willReturn(CompletableFuture.completedFuture("Hello world")); String value = awaitResult(retry.executeCompletionStage(scheduler, helloWorldService::returnHelloWorld)); //Then assertThat(value).isEqualTo("Hello world"); // Then the helloWorldService should be invoked 1 time BDDMockito.then(helloWorldService).should(times(1)).returnHelloWorld(); assertThat(metricRegistry.getMetrics()).hasSize(4); assertThat(metricRegistry.getGauges().get("testPrefix.testName." + SUCCESSFUL_CALLS_WITH_RETRY).getValue()).isEqualTo(0L); assertThat(metricRegistry.getGauges().get("testPrefix.testName." + SUCCESSFUL_CALLS_WITHOUT_RETRY).getValue()).isEqualTo(1L); assertThat(metricRegistry.getGauges().get("testPrefix.testName." + FAILED_CALLS_WITH_RETRY).getValue()).isEqualTo(0L); assertThat(metricRegistry.getGauges().get("testPrefix.testName." + FAILED_CALLS_WITHOUT_RETRY).getValue()).isEqualTo(0L); }
@Test public void compare_only_right() { qProfileRules.activateAndCommit(dbSession, right, singleton(RuleActivation.create(xooRule1.getId()))); QProfileComparisonResult result = comparison.compare(dbSession, left, right); assertThat(result.left().getKee()).isEqualTo(left.getKee()); assertThat(result.right().getKee()).isEqualTo(right.getKee()); assertThat(result.same()).isEmpty(); assertThat(result.inLeft()).isEmpty(); assertThat(result.inRight()).isNotEmpty().containsOnlyKeys(xooRule1.getKey()); assertThat(result.modified()).isEmpty(); assertThat(result.collectRuleKeys()).containsOnly(xooRule1.getKey()); }
private void validateTriggerDependency(final FlowTrigger flowTrigger, final String name, final String type, final Map<String, String> params) { assertThat(flowTrigger.getDependencyByName(name)).isNotNull(); assertThat(flowTrigger.getDependencyByName(name).getType()).isEqualTo(type); assertThat(flowTrigger.getDependencyByName(name).getProps()).isEqualTo(params); } }
@Test public void testEnvVariables() { Map<String, String> expected = System.getenv(); assertThat(System2.INSTANCE.envVariables()).isNotNull().isEqualTo(expected); }
@Test public void check_component_keys() { db.prepareDbUnit(getClass(), "shared.xml"); Map<String, Boolean> result = underTest.checkComponentKeys(dbSession, newArrayList("foo:struts", "foo:struts-core", "foo:struts-ui")); assertThat(result) .hasSize(3) .containsOnly(entry("foo:struts", false), entry("foo:struts-core", true), entry("foo:struts-ui", false)); }
@Test public void propagatesSpan() throws Exception { server.enqueue(new MockResponse()); get(client, "/foo"); RecordedRequest request = server.takeRequest(); assertThat(request.getHeaders().toMultimap()) .containsKeys("x-b3-traceId", "x-b3-spanId") .containsEntry("x-b3-sampled", asList("1")); takeSpan(); }
@Test public void testGetters() throws IOException { ProjectDefinition def = ProjectDefinition.create(); def.setKey("projectKey"); def.setName("projectName"); File baseDir = temp.newFolder(); def.setBaseDir(baseDir); def.setVersion("version"); def.setDescription("desc"); File workDir = temp.newFolder(); def.setWorkDir(workDir); def.setSources("file1"); def.setTests("test1"); AbstractProjectOrModule project = new DefaultInputProject(def); assertThat(project.key()).isEqualTo("projectKey"); assertThat(project.getName()).isEqualTo("projectName"); assertThat(project.getOriginalName()).isEqualTo("projectName"); assertThat(project.definition()).isEqualTo(def); assertThat(project.getBranch()).isNull(); assertThat(project.getBaseDir()).isEqualTo(baseDir.toPath()); assertThat(project.getKeyWithBranch()).isEqualTo("projectKey"); assertThat(project.getVersion()).isEqualTo("version"); assertThat(project.getOriginalVersion()).isEqualTo("version"); assertThat(project.getDescription()).isEqualTo("desc"); assertThat(project.getWorkDir()).isEqualTo(workDir.toPath()); assertThat(project.getEncoding()).isEqualTo(Charset.defaultCharset()); assertThat(project.properties()).hasSize(6); assertThat(project.isFile()).isFalse(); }
assertThat(result.getKey()).isEqualTo("ISSUE"); assertThat(result.getRuleKey()).isEqualTo(rule.getKey()); assertThat(result.getComponentUuid()).isEqualTo(file.uuid()); assertThat(result.getProjectUuid()).isEqualTo(project.uuid()); assertThat(result.getSeverity()).isEqualTo(BLOCKER); assertThat(result.getStatus()).isEqualTo(STATUS_OPEN); assertThat(result.getType()).isEqualTo(RuleType.BUG.getDbConstant()); assertThat(context.getStatistics().getAll()).containsOnly( entry("inserts", "1"), entry("updates", "0"), entry("merged", "0"), entry("untouched", "0"));
@Test public void test_definition_of_index() { IndexDefinition.IndexDefinitionContext context = new IndexDefinition.IndexDefinitionContext(); underTest.define(context); assertThat(context.getIndices()).hasSize(1); NewIndex ruleIndex = context.getIndices().get("rules"); assertThat(ruleIndex).isNotNull(); assertThat(ruleIndex.getTypes().keySet()).containsOnly("activeRule", "ruleExtension", "rule"); // no cluster by default assertThat(ruleIndex.getSettings().get("index.number_of_shards")).isEqualTo("2"); assertThat(ruleIndex.getSettings().get("index.number_of_replicas")).isEqualTo("0"); }
@Test public void nestedMessage() { assertThat(DOCSTRINGS).containsEntry( "armeria.grpc.testing.SimpleRequest.NestedRequest", " A request nested in another request.\n"); }
@Test public void test_defaults() { assertThat(underTest.getMethod()).isEqualTo(WsRequest.Method.GET); assertThat(underTest.getParams()).isEmpty(); assertThat(underTest.getMediaType()).isEqualTo(MediaTypes.JSON); assertThat(underTest.getPath()).isEqualTo("api/foo"); }
@Test public void test_mimetype_parser_does_parse_valid_mimetype_in_the_vendor_facet_with_a_json_suffix () throws ParserFailure { Optional<MimeType> oResult; MimeType mime; oResult = MimeTypeParser.parse("application/vnd.nike.runningcoach-v3.1+json"); assertThat(oResult.isPresent()).isTrue(); assertThat(oResult.get()).isNotNull(); mime = oResult.get(); assertThat(mime.getType()).isEqualTo(MimeType.Type.APPLICATION); assertThat(mime.getSubType().getName()).isEqualTo("nike.runningcoach-v3.1"); assertThat(mime.getSubType().getFacet()).isEqualTo(MimeType.Facet.VENDOR); assertThat(mime.getSubType().getSuffix()).isNotNull(); assertThat(mime.getSubType().getSuffix().get()).isNotNull(); assertThat(mime.getSubType().getSuffix().get()).isEqualTo("json"); assertThat(mime.getParameters()).isNotNull(); assertThat(mime.getParameters()).isEmpty(); }
@Test public void testMonitorAsyncMethods() throws Exception { testClass.asyncMethod(); final SpanContextInformation spanContext = spanCapturingReporter.get(); assertThat("TracedTransformerTest$TestClass#asyncMethod").isEqualTo(spanContext.getOperationName()); assertThat(1).isEqualTo(spanContext.getCallTree().getChildren().size()); final String signature = spanContext.getCallTree().getChildren().get(0).getSignature(); assertThat(signature).contains("org.stagemonitor.tracing.TracedTransformerTest$TestClass.asyncMethod"); final Map<MetricName,Timer> timers = metricRegistry.getTimers(); assertThat(timers).containsKey(name("response_time").operationName("TracedTransformerTest$TestClass#asyncMethod").operationType("method_invocation").build()); }
@Test public void test_mimetype_parser_does_parse_valid_mimetype_in_the_vendor_facet_with_a_json_suffix_and_one_parameter () throws ParserFailure { Optional<MimeType> oResult; MimeType mime; oResult = MimeTypeParser.parse("application/vnd.nike.runningcoach-v3.1+json;charset=UTF-8"); assertThat(oResult.isPresent()).isTrue(); assertThat(oResult.get()).isNotNull(); mime = oResult.get(); assertThat(mime.getType()).isEqualTo(MimeType.Type.APPLICATION); assertThat(mime.getSubType().getName()).isEqualTo("nike.runningcoach-v3.1"); assertThat(mime.getSubType().getFacet()).isEqualTo(MimeType.Facet.VENDOR); assertThat(mime.getSubType().getSuffix()).isNotNull(); assertThat(mime.getSubType().getSuffix().get()).isNotNull(); assertThat(mime.getSubType().getSuffix().get()).isEqualTo("json"); assertThat(mime.getParameters()).isNotNull(); assertThat(mime.getParameters()).isNotEmpty(); assertThat(mime.getParameters().get("charset")).isNotNull(); assertThat(mime.getParameters().get("charset")).isEqualTo("UTF-8"); }
Long processInstanceId = processClient.startProcess(CONTAINER_ALIAS, PROCESS_ID_EVALUATION, parameters); assertThat(processInstanceId).isNotNull().isGreaterThan(0); assertThat(processInstance).isNotNull(); assertThat(processInstance.getContainerId()).isEqualTo(CONTAINER_ID); assertThat(personVariable).isNotNull(); assertThat(personClass).isAssignableFrom(personVariable.getClass()); assertThat(variables).isNotNull(); assertThat(variables).hasSize(5); assertThat(variables).containsKey("test"); assertThat(variables).containsKey("number"); assertThat(variables).containsKey("list"); assertThat(variables).containsKey("person"); assertThat(variables).containsKey("initiator"); assertThat(variables.get("test")).isNotNull(); assertThat(variables.get("number")).isNotNull(); assertThat(variables.get("list")).isNotNull(); assertThat(variables.get("initiator")).isNotNull(); assertThat(String.class).isAssignableFrom(variables.get("test").getClass()); assertThat(Integer.class).isAssignableFrom(variables.get("number").getClass()); assertThat(List.class).isAssignableFrom(variables.get("list").getClass()); assertThat(personClass).isAssignableFrom(variables.get("person").getClass());
@Test public void testB3HeaderContextPropagation() throws Exception { HttpRequest httpRequest = new MockClientHttpRequest(HttpMethod.GET, new URI("http://example.com/foo?bar=baz")); new SpringRestTemplateContextPropagatingInterceptor(tracingPlugin) .intercept(httpRequest, null, mock(ClientHttpRequestExecution.class)); assertThat(httpRequest.getHeaders()).containsKey(B3HeaderFormat.SPAN_ID_NAME); assertThat(httpRequest.getHeaders()).containsKey(B3HeaderFormat.TRACE_ID_NAME); assertThat(mockTracer.finishedSpans()).hasSize(1); assertThat(mockTracer.finishedSpans().get(0).operationName()).isEqualTo("GET http://example.com/foo"); }
@Test public void compare_empty_profiles() { QProfileComparisonResult result = comparison.compare(dbSession, left, right); assertThat(result.left().getKee()).isEqualTo(left.getKee()); assertThat(result.right().getKee()).isEqualTo(right.getKee()); assertThat(result.same()).isEmpty(); assertThat(result.inLeft()).isEmpty(); assertThat(result.inRight()).isEmpty(); assertThat(result.modified()).isEmpty(); assertThat(result.collectRuleKeys()).isEmpty(); }
@Test public void loadPropsFromCommandLineArgs_load_properties_from_file() throws Exception { File propsFile = temp.newFile(); FileUtils.write(propsFile, "foo=bar"); Props result = ConfigurationUtils.loadPropsFromCommandLineArgs(new String[] {propsFile.getAbsolutePath()}); assertThat(result.value("foo")).isEqualTo("bar"); assertThat(result.rawProperties()).hasSize(1); }
Type type = queryParameterAdapter.getType(); assertThat(queryParameterAdapter.getIn()).isEqualTo("Query"); assertThat(type).isInstanceOf(BasicType.class); assertThat(type.getName()).isEqualTo("Version"); assertThat(type.getUniqueName()).isEqualTo("Version"); assertThat(((BasicType) type).getType()).isEqualTo("string"); assertThat(bodyParameterAdapter.getIn()).isEqualTo("Body"); assertThat(type).isInstanceOf(RefType.class); Type refType = ((RefType) type).getRefType(); assertThat(refType).isInstanceOf(ObjectType.class); ObjectType objectType = (ObjectType) refType; assertThat(objectType.getProperties()).hasSize(3); assertThat(bodyParameterAdapter.getInlineDefinitions()).hasSize(1);
@Test public void handle_messageContentHasJavaLabel() throws Exception { //when handler.handle(message); //then Message sentMessage = kernel.getSentMessages().get(0); Map<String, Serializable> map = sentMessage.getContent(); Assertions.assertThat(map).isNotNull(); Assertions.assertThat(map.get("implementation")).isEqualTo("java"); }