Java Code Examples for org.testng.Assert.assertNotNull()

The following are Jave code examples for showing how to use assertNotNull() of the org.testng.Assert class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: stock-api-sdk   File: HttpUtilsTest.java   View Source Code Vote up 6 votes
@Test(groups = "HttpsUtils.initialize")
public void initialize_should_return_httpClient_object() {
    Method method = null;
    try {
        method = HttpUtils.class.getDeclaredMethod("initialize");
        method.setAccessible(true);

        HttpClient httpClient = (HttpClient) method.invoke(null);

        method.setAccessible(false);
        Assert.assertNotNull(httpClient);
        Assert.assertTrue(httpClient instanceof CloseableHttpClient);
    } catch (Exception e) {
        try {
            if (method != null)
                method.setAccessible(false);
        } catch (Exception e1) {
            Assert.fail("Unable to make initialize method private again!");
        }
        Assert.fail("initialize method invocation failed with reflection!");
    }
}
 
Example 2
Project: butterfly   File: FindFilesTest.java   View Source Code Vote up 6 votes
@Test
public void bothNonRecursiveOneFoundTest() {
    FindFiles findFiles =  new FindFiles("(bla.)", false).relative(".").setIncludeFolders(true).setIncludeFiles(true);
    TUExecutionResult executionResult = findFiles.execution(transformedAppFolder, transformationContext);
    Assert.assertEquals(executionResult.getType(), TUExecutionResult.Type.VALUE);
    Assert.assertNotNull(executionResult.getValue());

    List<File> files = (List<File>) executionResult.getValue();
    Assert.assertEquals(files.size(), 1);

    Assert.assertTrue(files.contains(new File(transformedAppFolder, "./blah")));

    Assert.assertEquals(findFiles.getNameRegex(), "(bla.)");
    Assert.assertNull(findFiles.getPathRegex());
    Assert.assertFalse(findFiles.isRecursive());
    Assert.assertTrue(findFiles.isIncludeFiles());
    Assert.assertTrue(findFiles.isIncludeFolders());
    Assert.assertEquals(findFiles.getDescription(), "Find files whose name and/or path match regular expression and are under the root folder only (not including sub-folders)");
    Assert.assertNull(executionResult.getException());
}
 
Example 3
Project: hub-cf   File: BindResourceTest.java   View Source Code Vote up 5 votes
@Test
public void testBindResourceEmptyJson() {
    BindResource bindResource = JsonUtil.readValue(BIND_RESOURCE_EMPTY_JSON, BindResource.class);

    Assert.assertNotNull(bindResource, "BindResource deserialized object should not be null");
    Assert.assertFalse(bindResource.getAppGuid().isPresent(), "BindResource appGuid should not be present");
    Assert.assertFalse(bindResource.getRoute().isPresent(), "BindResource route should not be present");
}
 
Example 4
Project: openjdk-jdk10   File: HotSpotConstantReflectionProviderTest.java   View Source Code Vote up 5 votes
@Test(dataProvider = "forObjectDataProvider", dataProviderClass = ForObjectDataProvider.class)
public void testForObject(Object obj, String expected) {
    JavaConstant jConst = TestHelper.CONSTANT_REFLECTION_PROVIDER.forObject(obj);
    Assert.assertNotNull(jConst,
                    "An instance of JavaConstant returned by" + " \"forObject\" method should not be null");
    Assert.assertEquals(jConst.toString(), expected, "Unexpected result:");
}
 
Example 5
Project: keti   File: PolicyManagementServiceTest.java   View Source Code Vote up 5 votes
public void testCreatePolicySetPositive() {
    PolicySet policySet = this.jsonUtils.deserializeFromFile("set-with-1-policy.json", PolicySet.class);
    String policyName = policySet.getName();
    this.policyService.upsertPolicySet(policySet);
    PolicySet savedPolicySet = this.policyService.getPolicySet(policyName);
    Assert.assertNotNull(savedPolicySet);
    Assert.assertEquals(savedPolicySet.getPolicies().size(), 1);
    Assert.assertEquals(savedPolicySet.getPolicies().get(0).getTarget().getResource().getUriTemplate(),
            "/secured-by-value/sites/sanramon");
    this.policyService.deletePolicySet(policyName);
    Assert.assertEquals(this.policyService.getAllPolicySets().size(), 0);
}
 
Example 6
Project: openjdk-jdk10   File: ThenComposeAsyncTest.java   View Source Code Vote up 5 votes
public void testThenComposeAsync() throws Exception {
    // Composing CompletableFuture is complete
    CompletableFuture<String> cf1 = CompletableFuture.completedFuture("one");

    // Composing function returns a CompletableFuture executed asynchronously
    CountDownLatch cdl = new CountDownLatch(1);
    CompletableFuture<String> cf2 = cf1.thenCompose(str -> CompletableFuture.supplyAsync(() -> {
        while (true) {
            try {
                cdl.await();
                break;
            }
            catch (InterruptedException e) {
            }
        }
        return str + ", two";
    }));

    // Ensure returned CompletableFuture completes after call to thenCompose
    // This guarantees that any premature internal completion will be
    // detected
    cdl.countDown();

    String val = cf2.get();
    Assert.assertNotNull(val);
    Assert.assertEquals(val, "one, two");
}
 
Example 7
Project: bullet-core   File: PubSubMessageTest.java   View Source Code Vote up 5 votes
@Test
public void testWithMetadataAndSequenceCreation() {
    String messageID = getRandomString();
    String messageContent = getRandomString();
    String metadataContent = getRandomString();
    Signal signal = Signal.ACKNOWLEDGE;
    //Test creation with a sequence number.
    PubSubMessage message = new PubSubMessage(messageID, messageContent, new Metadata(signal, metadataContent), 0);
    Assert.assertTrue(messageID.equals(message.getId()));
    Assert.assertTrue(messageContent.equals(message.getContent()));
    Assert.assertEquals(message.getSequence(), 0);
    Assert.assertNotNull(message.getMetadata());
    Assert.assertEquals(message.getMetadata().getSignal(), signal);
    Assert.assertTrue(message.getMetadata().getContent().toString().equals(metadataContent));
}
 
Example 8
Project: amigo-chatbot   File: UserDAOTest.java   View Source Code Vote up 5 votes
@Override
public void testRemove() throws Exception {
    List<String> insertedIds = testCreateUser();
    Assert.assertNotNull(insertedIds);
    long countRemovedEntries = dao.remove(insertedIds);
    Assert.assertTrue(countRemovedEntries > 0, "Failed to delete any service");

}
 
Example 9
Project: hub-cf   File: BindResourceTest.java   View Source Code Vote up 5 votes
@Test
public void testBindResourceJsonAllPresent() {
    BindResource bindResource = JsonUtil.readValue(bindResourceJsonAllPresent, BindResource.class);

    Assert.assertNotNull(bindResource, "BindResource deserialized object should not be null");
    Assert.assertTrue(bindResource.getAppGuid().isPresent(), "BindResource appGuid should be present");
    Assert.assertTrue(bindResource.getRoute().isPresent(), "BindResource route should be present");

    Assert.assertEquals(bindResource.getAppGuid().get(), TEST_APPGUID, "BindResource appGuid incorrect");
    Assert.assertEquals(bindResource.getRoute().get(), TEST_ROUTE, "BindResource route incorrect");
}
 
Example 10
Project: ConfigJSR   File: ArrayConverterTest.java   View Source Code Vote up 5 votes
@Test
public void testFloatLookupProgrammatically() {
    Float[] value = config.getValue("tck.config.test.javaconfig.converter.floatvalues",
        Float[].class);
    Assert.assertNotNull(value);
    Assert.assertEquals(value.length, 2);

    Assert.assertEquals( value[0].floatValue(), 12.34f);
    Assert.assertEquals( value[1].floatValue(), 99.99f);

}
 
Example 11
Project: keti   File: AttributeConnectorControllerIT.java   View Source Code Vote up 5 votes
@Test(dataProvider = "requestUrlProvider")
public void testCreateResourceConnectorWithEmptyAdapters(final String endpointUrl) throws Exception {
    createZone1AndAssert();
    AttributeConnector connector = this.jsonUtils.deserializeFromFile(
            "controller-test/createAttributeConnectorWithEmptyAdapters.json", AttributeConnector.class);
    Assert.assertNotNull(connector, "createAttributeConnectorWithEmptyAdapters.json file not found or invalid");
    String connectorContent = this.objectWriter.writeValueAsString(connector);

    this.mockMvc.perform(
            put(endpointUrl).contentType(MediaType.APPLICATION_JSON).content(connectorContent))
            .andExpect(status().isUnprocessableEntity());
}
 
Example 12
Project: keti   File: ResourcePrivilegeManagementControllerIT.java   View Source Code Vote up 5 votes
@Test
public void testPUTResourceNoResourceId() throws Exception {

    BaseResource resource = JSON_UTILS
            .deserializeFromFile("controller-test/no-resourceIdentifier-resource.json", BaseResource.class);
    Assert.assertNotNull(resource);

    String thisUri = RESOURCE_BASE_URL + "/%2Fservices%2Fsecured-api%2Fsubresource";
    // Update a given resource
    MockMvcContext putContext =
        TEST_UTILS.createWACWithCustomPUTRequestBuilder(this.wac, this.testZone.getSubdomain(), thisUri);
    putContext.getMockMvc().perform(putContext.getBuilder().contentType(MediaType.APPLICATION_JSON)
            .content(OBJECT_MAPPER.writeValueAsString(resource))).andExpect(status().is2xxSuccessful());

    // Get a given resource
    MockMvcContext getContext =
        TEST_UTILS.createWACWithCustomGETRequestBuilder(this.wac, this.testZone.getSubdomain(), thisUri);
    getContext.getMockMvc().perform(getContext.getBuilder()).andExpect(status().isOk())
            .andExpect(jsonPath("resourceIdentifier", is("/services/secured-api/subresource")))
            .andExpect(jsonPath("attributes[0].value", isIn(new String[] { "supervisor", "it" })))
            .andExpect(jsonPath("attributes[0].issuer", is("https://acs.attributes.int")));

    // Delete a given resource
    MockMvcContext deleteContext =
        TEST_UTILS.createWACWithCustomDELETERequestBuilder(this.wac, this.testZone.getSubdomain(), thisUri);
    deleteContext.getMockMvc().perform(deleteContext.getBuilder()).andExpect(status().isNoContent());
}
 
Example 13
Project: dhus-core   File: TestConfigurationManager.java   View Source Code Vote up 5 votes
@Test
public void testgetSendLogsCronConfiguration ()
{
   Assert.assertNotNull (configurationManager.getSendLogsCronConfiguration ());
   Assert.assertEquals (configurationManager.getSendLogsCronConfiguration ().getSchedule (), "0 0 0 ? * *");
   Assert.assertEquals (configurationManager.getSendLogsCronConfiguration ().getAddresses (), "[email protected]");
}
 
Example 14
Project: keti   File: JsonUtilsTest.java   View Source Code Vote up 5 votes
private void assertStudentJsonNode(final JsonNode studentJsonNode) {
    Assert.assertNotNull(studentJsonNode);
    Assert.assertEquals(studentJsonNode.findValuesAsText("id").get(0), "S00001");
    Assert.assertEquals(studentJsonNode.findValuesAsText("name").get(0), "Joe");
    Assert.assertEquals(studentJsonNode.findValuesAsText("age").get(0), "15");
    Assert.assertEquals(studentJsonNode.findValue("courses").get(0).asText(), "Math");
    Assert.assertEquals(studentJsonNode.findValue("courses").get(1).asText(), "Arts");
}
 
Example 15
Project: keti   File: GroovyConditionScriptTest.java   View Source Code Vote up 5 votes
/**
 * Test the execution of a policy condition, which tries to assign null, to a variable.
 *
 * @throws ConditionParsingException
 */
@Test
public void testScriptExecutionUsingAssignment() throws ConditionParsingException {
    String script = "resource = null; resource == null;";
    ConditionScript parsedScript = this.shell.parse(script);
    Map<String, Object> parameter = new HashMap<>();
    final ResourceHandler resourceHandler = new ResourceHandler(new HashSet<Attribute>(), "", "");
    parameter.put("resource", resourceHandler);
    Assert.assertEquals(parsedScript.execute(parameter), true);
    Assert.assertNotNull(resourceHandler);
}
 
Example 16
Project: dhus-core   File: MetadataTypeServiceTest.java   View Source Code Vote up 5 votes
@Test
public void getMetadataTypeByName()
{
   Assert.assertNotNull(service.getMetadataTypeByName(
      "http://www.gael.fr/test#product1",
      "Satellite number"));
}
 
Example 17
Project: stock-api-sdk   File: LicenseEntitlementQuotaTest.java   View Source Code Vote up 4 votes
@BeforeSuite
void creating_LicenseEntitlementQuota_InstanceSuccessfully() {
    entitlementQuota = new LicenseEntitlementQuota();
    Assert.assertNotNull(entitlementQuota);
}
 
Example 18
Project: bullet-core   File: GroupByTest.java   View Source Code Vote up 4 votes
@Test
public void testMetadata() {
    Map<String, String> fields = singletonMap("fieldA", null);
    // Nominal Entries is 32. Aggregation size is also 32
    GroupBy groupBy = makeGroupBy(makeConfiguration(32), fields, 32,
                                  singletonList(makeGroupOperation(COUNT, null, null)), ALL_METADATA);

    // Generate 4 batches of 64 records with 0 - 63 in fieldA.
    IntStream.range(0, 256).mapToObj(i -> RecordBox.get().add("fieldA", i % 64).getRecord()).forEach(groupBy::consume);
    Clip aggregate = groupBy.getAggregation();
    Assert.assertNotNull(aggregate);

    List<BulletRecord> records = aggregate.getRecords();
    Assert.assertEquals(records.size(), 32);
    records.forEach(r -> Assert.assertTrue(Integer.valueOf(r.get("fieldA").toString()) < 64));

    Map<String, Object> meta = aggregate.getMeta().asMap();
    Assert.assertEquals(meta.size(), 1);

    Map<String, Object> stats = (Map<String, Object>) meta.get("aggregate_stats");
    Assert.assertEquals(stats.size(), 4);

    Assert.assertTrue((Boolean) stats.get("isEstimate"));

    double theta = (Double) stats.get("theta");
    Assert.assertTrue(theta <= 1.0);

    double groupEstimate = (Double) stats.get("uniquesApprox");

    Assert.assertTrue(stats.containsKey("stddev"));
    Map<String, Map<String, Double>> standardDeviations = (Map<String, Map<String, Double>>) stats.get("stddev");
    Assert.assertEquals(standardDeviations.size(), 3);

    double upperOneSigma = standardDeviations.get(KMVSketch.META_STD_DEV_1).get(KMVSketch.META_STD_DEV_UB);
    double lowerOneSigma = standardDeviations.get(KMVSketch.META_STD_DEV_1).get(KMVSketch.META_STD_DEV_LB);
    double upperTwoSigma = standardDeviations.get(KMVSketch.META_STD_DEV_2).get(KMVSketch.META_STD_DEV_UB);
    double lowerTwoSigma = standardDeviations.get(KMVSketch.META_STD_DEV_2).get(KMVSketch.META_STD_DEV_LB);
    double upperThreeSigma = standardDeviations.get(KMVSketch.META_STD_DEV_3).get(KMVSketch.META_STD_DEV_UB);
    double lowerThreeSigma = standardDeviations.get(KMVSketch.META_STD_DEV_3).get(KMVSketch.META_STD_DEV_LB);

    Assert.assertTrue(groupEstimate >= lowerOneSigma);
    Assert.assertTrue(groupEstimate <= upperOneSigma);
    Assert.assertTrue(groupEstimate >= lowerTwoSigma);
    Assert.assertTrue(groupEstimate <= upperTwoSigma);
    Assert.assertTrue(groupEstimate >= lowerThreeSigma);
    Assert.assertTrue(groupEstimate <= upperThreeSigma);
    Assert.assertTrue(groupEstimate <= upperThreeSigma);
}
 
Example 19
Project: allure-report-processor   File: TestAllureReportProcessor.java   View Source Code Vote up 4 votes
@Test (enabled = false)
public void removeDuplicateTestsWhenInputReportDirAndThereAreNoDuplicateTests() throws Exception {
	AllureReportProcessor processor = new AllureReportProcessor(ALLURE_REPORT_DIR_DO_NOT_HAVE_DUPLICATE_TESTS);
	Assert.assertNotNull(processor.removeDuplicateTests());
}
 
Example 20
Project: openjdk-jdk10   File: HotSpotConstantReflectionProviderTest.java   View Source Code Vote up 4 votes
@Test
public void testGetMethodHandleAccess() {
    MethodHandleAccessProvider actual = CONSTANT_REFLECTION_PROVIDER.getMethodHandleAccess();
    Assert.assertNotNull(actual,
                    "Returned MethodHandleAccessProvider instance should not be null");
}