@Test public void testGet_methodElementReturnsNullAtFileScope() { Scope scope = new FileScope(); MethodElement key = new MethodElement("foo"); assertThat(scope.get(key)).isNull(); }
@Test public void testGet_methodElementFetchedFromMethodScope() { Scope fileScope = new FileScope(); Scope methodScope1 = new MethodScope(fileScope); Scope methodScope2 = new MethodScope(fileScope); MethodElement key = new MethodElement("foo"); assertThat(fileScope.get(key)).isNull(); assertThat(methodScope1.get(key)).isNull(); assertThat(methodScope2.get(key)).isNull(); methodScope1.putIfAbsent(key, 1); assertThat(fileScope.get(key)).isNull(); assertThat(methodScope1.get(key)).isEqualTo(1); assertThat(methodScope2.get(key)).isNull(); methodScope1.putIfAbsent(key, 2); assertThat(fileScope.get(key)).isNull(); assertThat(methodScope1.get(key)).isEqualTo(1); assertThat(methodScope2.get(key)).isNull(); methodScope2.putIfAbsent(key, 3); assertThat(fileScope.get(key)).isNull(); assertThat(methodScope1.get(key)).isEqualTo(1); assertThat(methodScope2.get(key)).isEqualTo(3); }
@Test public void testPutIfAbsent_methodElementStoredInMethodScope() { Scope fileScope = new FileScope(); Scope methodScope1 = new MethodScope(fileScope); Scope methodScope2 = new MethodScope(fileScope); MethodElement key = new MethodElement("foo"); Integer existingValue1 = methodScope1.putIfAbsent(key, 1); assertThat(existingValue1).isNull(); Integer existingValue2 = methodScope1.putIfAbsent(key, 2); assertThat(existingValue2).isEqualTo(1); Integer existingValue3 = methodScope1.putIfAbsent(key, 3); assertThat(existingValue3).isEqualTo(1); Integer existingValue4 = methodScope2.putIfAbsent(key, 4); assertThat(existingValue4).isNull(); }
@Test public void noClassifier_GetOptionalNotRegistered() { // when Integer dependency = scope.getOptional(Integer.class); // then assertThat(dependency).isNull(); }
@Test public void classifier_GetOptionalNotRegistered() { // when Integer dependency = scope.getOptional(Integer.class, "common"); // then assertThat(dependency).isNull(); }
@Test public void classifier_GetOptionalRegisteredWrongClassifier() { // given scope.bind(Integer.class, 100, "common"); // when Integer dependency = scope.getOptional(Integer.class, "wrong"); // then assertThat(dependency).isNull(); }
@Test public void classifier_GetOptionalRegisteredNoClassifier() { // given scope.bind(Integer.class, 100, "common"); // when Integer dependency = scope.getOptional(Integer.class); // then assertThat(dependency).isNull(); }
@Test public void emptyCdepYml() throws Exception { CDepYml config = new CDepYml(); System.out.printf(new Yaml().dump(config)); File yaml = new File(".test-files/emptyCdepYml/cdep.yml"); yaml.getParentFile().mkdirs(); Files.write("", yaml, StandardCharsets.UTF_8); try { String result = main("-wf", yaml.getParent()); System.out.print(result); fail("Expected failure"); } catch (CDepRuntimeException e) { assertThat(e.getMessage()).endsWith("cdep.yml was empty"); assertThat(e.errorInfo.file).endsWith("cdep.yml"); assertThat(e.errorInfo.line).isNull(); assertThat(e.errorInfo.code).isEqualTo("137b0ec"); } }
@Test public void testNullResult() throws Exception { BatchedFuture<Integer> batchedFuture = BatchedFuture.<Integer>create(); BatchedRequestIssuer<Integer> issuer = new BatchedRequestIssuer<>(batchedFuture, 2); issuer.setResponse(null); Truth.assertThat(batchedFuture.isDone()).isFalse(); issuer.sendResult(); Truth.assertThat(batchedFuture.isDone()).isTrue(); Truth.assertThat(batchedFuture.get()).isNull(); }
assertThat(spanData.getMessageEvents()).isEqualTo(messageEvents); assertThat(spanData.getLinks()).isEqualTo(links); assertThat(spanData.getChildSpanCount()).isNull(); assertThat(spanData.getStatus()).isNull(); assertThat(spanData.getEndTimestamp()).isNull();