Java Code Examples for org.junit.jupiter.api.Assertions#assertNull()

The following examples show how to use org.junit.jupiter.api.Assertions#assertNull() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListenerOkHttpTest.java    From symbol-sdk-java with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldFilterOutHandleStatus()
    throws InterruptedException, ExecutionException, TimeoutException {
    Account account1 = Account.generateNewAccount(NetworkType.MIJIN_TEST);
    Account account2 = Account.generateNewAccount(NetworkType.MIJIN_TEST);

    AtomicReference<TransactionStatusError> reference = new AtomicReference<>();

    simulateWebSocketStartup();
    Assertions.assertNotNull(listener.status(account2.getAddress()).subscribe(reference::set));

    Map<String, Object> message = new HashMap<>();
    message.put("hash", "1234hash");
    message.put("address", account1.getAddress().encoded());
    message.put("code", "some error");
    message.put("deadline", 5555);
    listener.handle(message, null);

    Assertions.assertNull(reference.get());

    Mockito.verify(webSocketMock)
        .send(jsonHelper
            .print(new ListenerSubscribeMessage(this.wsId,
                "status" + "/" + account2.getAddress().plain())));
}
 
Example 2
Source File: PanacheMockingTest.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@Test
public void testPanacheRepositoryBridges() {
    // normal method call
    Assertions.assertNull(realPersonRepository.findById(0l));
    // bridge call
    Assertions.assertNull(((PanacheRepositoryBase) realPersonRepository).findById(0l));
    // normal method call
    Assertions.assertNull(realPersonRepository.findById(0l, LockModeType.NONE));
    // bridge call
    Assertions.assertNull(((PanacheRepositoryBase) realPersonRepository).findById(0l, LockModeType.NONE));

    // normal method call
    Assertions.assertEquals(Optional.empty(), realPersonRepository.findByIdOptional(0l));
    // bridge call
    Assertions.assertEquals(Optional.empty(), ((PanacheRepositoryBase) realPersonRepository).findByIdOptional(0l));
    // normal method call
    Assertions.assertEquals(Optional.empty(), realPersonRepository.findByIdOptional(0l, LockModeType.NONE));
    // bridge call
    Assertions.assertEquals(Optional.empty(),
            ((PanacheRepositoryBase) realPersonRepository).findByIdOptional(0l, LockModeType.NONE));

    // normal method call
    Assertions.assertEquals(false, realPersonRepository.deleteById(0l));
    // bridge call
    Assertions.assertEquals(false, ((PanacheRepositoryBase) realPersonRepository).deleteById(0l));
}
 
Example 3
Source File: ReachAssertionVerificationCommandTests.java    From workcraft with MIT License 6 votes vote down vote up
@Test
public void testVmeVerification() throws DeserialisationException {
    String workName = PackageUtils.getPackagePath(getClass(), "vme.stg.work");

    final Framework framework = Framework.getInstance();
    final ClassLoader classLoader = ClassLoader.getSystemClassLoader();
    URL url = classLoader.getResource(workName);
    WorkspaceEntry we = framework.loadWork(url.getFile());

    ReachAssertionVerificationCommand command = new ReachAssertionVerificationCommand();
    Assertions.assertNull(command.execute(we, command.deserialiseData("incorrect - expression")));
    Assertions.assertFalse(command.execute(we, command.deserialiseData("$S\"dsr\" ^ $S\"dsw\"")));
    Assertions.assertTrue(command.execute(we, command.deserialiseData("$S\"dsr\" & $S\"dsw\"")));

    // Should be True because of the inversePredicate=false
    Assertions.assertTrue(command.execute(we, command.deserialiseData(
            "<settings inversePredicate=\"false\"><reach>$S\"dsr\" ^ $S\"dsw\"</reach></settings>")));

    // Should be False because of the inversePredicate=false
    Assertions.assertFalse(command.execute(we, command.deserialiseData(
            "<settings inversePredicate=\"false\"><reach>$S\"dsr\" &amp; $S\"dsw\"</reach></settings>")));
}
 
Example 4
Source File: BatchOptionsTest.java    From influxdb-java with MIT License 5 votes vote down vote up
/**
 * Test the implementation of {@link BatchOptions#jitterDuration(int)} }.
 * @throws InterruptedException
 */
@Test
public void testJitterDuration() throws InterruptedException {

  String dbName = "write_unittest_" + System.currentTimeMillis();
  try {
    BatchOptions options = BatchOptions.DEFAULTS.flushDuration(100).jitterDuration(500);
    influxDB.query(new Query("CREATE DATABASE " + dbName));
    influxDB.setDatabase(dbName);
    influxDB.enableBatch(options);
    write20Points(influxDB);

    Thread.sleep(100);

    QueryResult result = influxDB.query(new Query("select * from weather", dbName));
    Assertions.assertNull(result.getResults().get(0).getSeries());
    Assertions.assertNull(result.getResults().get(0).getError());

    //wait for at least one flush
    Thread.sleep(1000);
    result = influxDB.query(new Query("select * from weather", dbName));
    Assertions.assertEquals(20, result.getResults().get(0).getSeries().get(0).getValues().size());
  }
  finally {
    influxDB.disableBatch();
    influxDB.query(new Query("DROP DATABASE " + dbName));
  }


}
 
Example 5
Source File: GetFileDiffControllerTest.java    From coderadar with MIT License 5 votes vote down vote up
@Test
void testGetFileDiff() throws Exception {
  GetFileDiffCommand getFileDiffCommand =
      new GetFileDiffCommand(
          "e9f7ff6fdd8c0863fdb5b24c9ed35a3651e20382", "testModule1/NewRandomFile.java");

  MvcResult result =
      mvc()
          .perform(
              get("/api/projects/" + projectId + "/files/diff")
                  .contentType(MediaType.APPLICATION_JSON)
                  .content(toJson(getFileDiffCommand)))
          .andDo(
              document(
                  "files/diff",
                  requestFields(
                      fieldWithPath("commitHash")
                          .description("The commit whose file tree to search in."),
                      fieldWithPath("filepath").description("The path of the file")),
                  responseFields(
                      fieldWithPath("content")
                          .description("The diff against the same file in the parent commit"),
                      subsectionWithPath("metrics").description("Always null"))))
          .andReturn();

  FileContentWithMetrics fileContentWithMetrics =
      fromJson(result.getResponse().getContentAsString(), FileContentWithMetrics.class);

  Assertions.assertEquals(
      "@@ -1 +1,2 @@\n"
          + " public class this does not compile\n"
          + "+// This test still does not compile\n"
          + "\\ No newline at end of file\n",
      fileContentWithMetrics.getContent());

  Assertions.assertNull(fileContentWithMetrics.getMetrics());
}
 
Example 6
Source File: LanguageMapperTest.java    From voj with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 测试用例: 测试deleteLanguage(int)方法
 * 测试数据: Ruby语言的编程语言唯一标识符
 * 预期结果: 数据删除操作成功完成
 */
@Test
public void testDeleteLanguageExists() {
	Language language = languageMapper.getLanguageUsingId(6);
	Assertions.assertNotNull(language);
	
	int numberOfRowsAffected = languageMapper.deleteLanguage(6);
	Assertions.assertEquals(1, numberOfRowsAffected);
	
	language = languageMapper.getLanguageUsingId(6);
	Assertions.assertNull(language);
}
 
Example 7
Source File: RunAsTest.java    From alfresco-mvc with Apache License 2.0 5 votes vote down vote up
@Test
public void noAutehntication_runAsSystem() {
	service.getNamePropertyAsSystem(nodeRef);

	Assertions.assertNull(AuthenticationUtil.getRunAsUser());
	Assertions.assertNull(AuthenticationUtil.getFullyAuthenticatedUser());
}
 
Example 8
Source File: SearchCriteriaTest.java    From symbol-sdk-java with Apache License 2.0 5 votes vote down vote up
@Test
void shouldCreate() {
    SearchCriteria criteria = new SearchCriteria();
    Assertions.assertNull(criteria.getOrder());
    Assertions.assertNull(criteria.getPageSize());
    Assertions.assertNull(criteria.getPageNumber());
}
 
Example 9
Source File: SpotAssertionVerificationCommandTests.java    From workcraft with MIT License 5 votes vote down vote up
@Test
public void testVmeVerification() throws DeserialisationException {
    String workName = PackageUtils.getPackagePath(getClass(), "vme-tm.circuit.work");

    final Framework framework = Framework.getInstance();
    final ClassLoader classLoader = ClassLoader.getSystemClassLoader();
    URL url = classLoader.getResource(workName);
    WorkspaceEntry we = framework.loadWork(url.getFile());

    SpotAssertionVerificationCommand command = new SpotAssertionVerificationCommand();
    Assertions.assertNull(command.execute(we, command.deserialiseData("incorrect - expression")));
    Assertions.assertFalse(command.execute(we, command.deserialiseData("G((\"dsr\") & (\"dsw\"))")));
    Assertions.assertTrue(command.execute(we, command.deserialiseData("G((!\"dsr\") | (!\"dsw\"))")));
}
 
Example 10
Source File: PandaPipelinePathTest.java    From panda with Apache License 2.0 5 votes vote down vote up
@Test
void getTotalHandleTime() {
    Assertions.assertNull(defaultPath.getPipeline(TEST_COMPONENT)
            .handle(new PandaContext(), new PandaChannel(), PandaTokenInfo.of(TokenTypes.UNKNOWN, "test").toSnippet())
            .getParser().orElse(null));

    Assertions.assertTrue(defaultPath.getTotalHandleTime() > 0);
}
 
Example 11
Source File: ProblemCategoryMapperTest.java    From voj with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 测试用例: 测试deleteProblemCategory(int)方法
 * 测试数据: 不存在的试题分类唯一标识符
 * 预期结果: 方法正常执行, 未影响数据表中的数据
 */
@Test
public void testDeleteProblemCategoryNotExists() {
	ProblemCategory problemCategory = problemCategoryMapper.getProblemCategoryUsingCategoryId(0);
	Assertions.assertNull(problemCategory);

	int numberOfRowsAffected = problemCategoryMapper.deleteProblemCategory(0);
	Assertions.assertEquals(0, numberOfRowsAffected);
}
 
Example 12
Source File: MapperUtilsTest.java    From symbol-sdk-java with Apache License 2.0 5 votes vote down vote up
@Test
void toUnresolvedAddressFromAddress() {
    Assertions.assertNull(MapperUtils.toUnresolvedAddress(null));
    Address address = Address.generateRandom(networkType);
    Assertions.assertEquals(address, MapperUtils.toUnresolvedAddress(address.encoded(
        networkType)));

}
 
Example 13
Source File: SubnetIdProviderTest.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
@Test
void testProvideShouldReturnNullWhenNetworkNull() {
    String actual = underTest.provide(null, Tunnel.DIRECT, CloudPlatform.AWS);

    Assertions.assertNull(actual);
}
 
Example 14
Source File: RippersTest.java    From ripme with MIT License 4 votes vote down vote up
@Deprecated
void assertNull(Object actual) {
    Assertions.assertNull(actual);
}
 
Example 15
Source File: SdxConverterTest.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetSharedServiceWhenSdxNullAndEnvironmentHasNotSdx() {
    SharedServiceV4Request sdxRequest = underTest.getSharedService(null);

    Assertions.assertNull(sdxRequest);
}
 
Example 16
Source File: VersionConvertorPrimitiveType30_50Test.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
@ParameterizedTest(name = "Testing dstu3 -> r5 conversion of null value {0}.")
@MethodSource("dstu3PrimitiveTypes")
public <T extends PrimitiveType> void testNullValueDstu2Primitive(String classname, T obj) {
  obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new StringType("A value"));
  Assertions.assertNull(((org.hl7.fhir.r5.model.PrimitiveType) VersionConvertor_30_50.convertType(obj)).getValue());
}
 
Example 17
Source File: ServerGroupTest.java    From spectator with Apache License 2.0 4 votes vote down vote up
@Test
public void getShardsOnlyShard2() {
  String asg = "app-stack-x2shard2-detail-v000";
  Assertions.assertNull(ServerGroup.parse(asg).shard1());
  Assertions.assertEquals("shard2", ServerGroup.parse(asg).shard2());
}
 
Example 18
Source File: CanonicalResourceManagerTester.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
@Test
public void testSingleWithDuplicateIds2() {
  CanonicalResourceManager<ValueSet> mrm = new CanonicalResourceManager<>(true);
  ValueSet vs1 = new ValueSet();
  vs1.setId("2345");
  vs1.setUrl("http://url/ValueSet/234");
  vs1.setVersion("4.0.1");
  vs1.setName("1");
  
  ValueSet vs2 = new ValueSet();
  vs2.setId("2345");
  vs2.setUrl("http://url/ValueSet/234");
  vs2.setVersion("4.0.2");
  vs2.setName("2");
  
  mrm.clear();
  mrm.see(vs1, null);
  
  Assertions.assertEquals(mrm.size(), 1);
  Assertions.assertNotNull(mrm.get("2345"));
  Assertions.assertEquals(mrm.get("2345").getName(), "1");
  Assertions.assertNotNull(mrm.get("http://url/ValueSet/234"));
  Assertions.assertEquals(mrm.get("http://url/ValueSet/234").getName(), "1");
  Assertions.assertNotNull(mrm.get("http://url/ValueSet/234", "4.0.0"));
  Assertions.assertEquals(mrm.get("http://url/ValueSet/234", "4.0.0").getName(), "1");
  Assertions.assertNotNull(mrm.get("http://url/ValueSet/234", "4.0.1"));
  Assertions.assertEquals(mrm.get("http://url/ValueSet/234", "4.0.1").getName(), "1");
  Assertions.assertNotNull(mrm.get("http://url/ValueSet/234", "4.0.2"));
  Assertions.assertEquals(mrm.get("http://url/ValueSet/234", "4.0.2").getName(), "1");
  Assertions.assertNotNull(mrm.get("http://url/ValueSet/234", "4.0"));
  Assertions.assertEquals(mrm.get("http://url/ValueSet/234", "4.0").getName(), "1");
  Assertions.assertNull(mrm.get("http://url/ValueSet/234", "4.1"));

  mrm.see(vs2, null);

  Assertions.assertEquals(mrm.size(), 1);
  Assertions.assertNotNull(mrm.get("2345"));
  Assertions.assertEquals(mrm.get("2345").getName(), "2");
  
  Assertions.assertNotNull(mrm.get("http://url/ValueSet/234"));
  Assertions.assertEquals(mrm.get("http://url/ValueSet/234").getName(), "2");
  Assertions.assertNotNull(mrm.get("http://url/ValueSet/234", "4.0.0"));
  Assertions.assertEquals(mrm.get("http://url/ValueSet/234", "4.0.0").getName(), "2");
  Assertions.assertNotNull(mrm.get("http://url/ValueSet/234", "4.0.1"));
  Assertions.assertEquals(mrm.get("http://url/ValueSet/234", "4.0.1").getName(), "2");
  Assertions.assertNotNull(mrm.get("http://url/ValueSet/234", "4.0.2"));
  Assertions.assertEquals(mrm.get("http://url/ValueSet/234", "4.0.2").getName(), "2");
  Assertions.assertNotNull(mrm.get("http://url/ValueSet/234", "4.0"));
  Assertions.assertEquals(mrm.get("http://url/ValueSet/234", "4.0").getName(), "2");
  Assertions.assertNull(mrm.get("http://url/ValueSet/234", "4.1"));

  mrm.drop("2345"); // vs2;
  Assertions.assertEquals(mrm.size(), 0);
  Assertions.assertNull(mrm.get("2345"));
  Assertions.assertNull(mrm.get("2346"));
  Assertions.assertNull(mrm.get("http://url/ValueSet/234"));
  Assertions.assertNull(mrm.get("http://url/ValueSet/234", "4.0.0"));
  Assertions.assertNull(mrm.get("http://url/ValueSet/234", "4.0.1"));
  Assertions.assertNull(mrm.get("http://url/ValueSet/234", "4.0.2"));
  Assertions.assertNull(mrm.get("http://url/ValueSet/234", "4.0"));
  Assertions.assertNull(mrm.get("http://url/ValueSet/234", "4.1"));
}
 
Example 19
Source File: CanonicalResourceManagerTester.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
@Test
public void testSingleWithVersions2() {
  CanonicalResourceManager<ValueSet> mrm = new CanonicalResourceManager<>(true);
  ValueSet vs1 = new ValueSet();
  vs1.setId("2345");
  vs1.setUrl("http://url/ValueSet/234");
  vs1.setVersion("4.0.1");
  vs1.setName("1");
  
  ValueSet vs2 = new ValueSet();
  vs2.setId("2346");
  vs2.setUrl("http://url/ValueSet/234");
  vs2.setVersion("4.0.2");
  vs2.setName("2");
  
  mrm.clear();
  mrm.see(vs1, null);
  
  Assertions.assertEquals(mrm.size(), 1);
  Assertions.assertNotNull(mrm.get("2345"));
  Assertions.assertEquals(mrm.get("2345").getName(), "1");
  Assertions.assertNotNull(mrm.get("http://url/ValueSet/234"));
  Assertions.assertEquals(mrm.get("http://url/ValueSet/234").getName(), "1");
  Assertions.assertNotNull(mrm.get("http://url/ValueSet/234", "4.0.0"));
  Assertions.assertEquals(mrm.get("http://url/ValueSet/234", "4.0.0").getName(), "1");
  Assertions.assertNotNull(mrm.get("http://url/ValueSet/234", "4.0.1"));
  Assertions.assertEquals(mrm.get("http://url/ValueSet/234", "4.0.1").getName(), "1");
  Assertions.assertNotNull(mrm.get("http://url/ValueSet/234", "4.0.2"));
  Assertions.assertEquals(mrm.get("http://url/ValueSet/234", "4.0.2").getName(), "1");
  Assertions.assertNotNull(mrm.get("http://url/ValueSet/234", "4.0"));
  Assertions.assertEquals(mrm.get("http://url/ValueSet/234", "4.0").getName(), "1");
  Assertions.assertNull(mrm.get("http://url/ValueSet/234", "4.1"));

  mrm.see(vs2, null);

  Assertions.assertEquals(mrm.size(), 2);
  Assertions.assertNotNull(mrm.get("2345"));
  Assertions.assertEquals(mrm.get("2345").getName(), "1");
  Assertions.assertNotNull(mrm.get("2346"));
  Assertions.assertEquals(mrm.get("2346").getName(), "2");
  
  Assertions.assertNotNull(mrm.get("http://url/ValueSet/234"));
  Assertions.assertEquals(mrm.get("http://url/ValueSet/234").getName(), "2");
  Assertions.assertNotNull(mrm.get("http://url/ValueSet/234", "4.0.0"));
  Assertions.assertEquals(mrm.get("http://url/ValueSet/234", "4.0.0").getName(), "2");
  Assertions.assertNotNull(mrm.get("http://url/ValueSet/234", "4.0.1"));
  Assertions.assertEquals(mrm.get("http://url/ValueSet/234", "4.0.1").getName(), "1");
  Assertions.assertNotNull(mrm.get("http://url/ValueSet/234", "4.0.2"));
  Assertions.assertEquals(mrm.get("http://url/ValueSet/234", "4.0.2").getName(), "2");
  Assertions.assertNotNull(mrm.get("http://url/ValueSet/234", "4.0"));
  Assertions.assertEquals(mrm.get("http://url/ValueSet/234", "4.0").getName(), "2");
  Assertions.assertNull(mrm.get("http://url/ValueSet/234", "4.1"));

  mrm.drop("2345"); // vs1;
  Assertions.assertEquals(mrm.size(), 1);
  Assertions.assertNull(mrm.get("2345"));
  Assertions.assertNotNull(mrm.get("2346"));
  Assertions.assertEquals(mrm.get("2346").getName(), "2");
  
  Assertions.assertNotNull(mrm.get("http://url/ValueSet/234"));
  Assertions.assertEquals(mrm.get("http://url/ValueSet/234").getName(), "2");
  Assertions.assertNotNull(mrm.get("http://url/ValueSet/234", "4.0.0"));
  Assertions.assertEquals(mrm.get("http://url/ValueSet/234", "4.0.0").getName(), "2");
  Assertions.assertNotNull(mrm.get("http://url/ValueSet/234", "4.0.1"));
  Assertions.assertEquals(mrm.get("http://url/ValueSet/234", "4.0.1").getName(), "2");
  Assertions.assertNotNull(mrm.get("http://url/ValueSet/234", "4.0.2"));
  Assertions.assertEquals(mrm.get("http://url/ValueSet/234", "4.0.2").getName(), "2");
  Assertions.assertNotNull(mrm.get("http://url/ValueSet/234", "4.0"));
  Assertions.assertEquals(mrm.get("http://url/ValueSet/234", "4.0").getName(), "2");
  Assertions.assertNull(mrm.get("http://url/ValueSet/234", "4.1"));
}
 
Example 20
Source File: ServerGroupTest.java    From spectator with Apache License 2.0 4 votes vote down vote up
@Test
public void getShardsForAppDetail() {
  String asg = "app--detail";
  Assertions.assertNull(ServerGroup.parse(asg).shard1());
  Assertions.assertNull(ServerGroup.parse(asg).shard2());
}