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

The following examples show how to use org.junit.jupiter.api.Assertions#assertDoesNotThrow() . 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: TransactionDetailTest.java    From evt4j with MIT License 6 votes vote down vote up
@Test
@DisplayName("Can create from json object")
void create() {
    Assertions.assertDoesNotThrow(() -> {
        JSONObject obj = new JSONObject();
        obj.put("block_num", 1);
        obj.put("packed_trx", "test_packed_trx");
        obj.put("id", "test_id");
        obj.put("compression", "test_compression");
        obj.put("signatures", JSONArray.parseArray(
                "[\"SIG_K1_Ke1xR6s7BfUFguPDNbGvH5SnWeKSZnXwepzWK1mWSyVaYkZ8zRDzZkmTNbaGUhwATt1VNV4kDatmvK96uahTsH3cQcKgqJ\", \"SIG_K1_Kg3UGU7UVDefMVZLnyDuzCEQarZf3vUFgwLzr3Hrovxdom4WWY5WQdinDNc2gVA98Rpf7Yg3ZGCmjNK13jVyFsnLTwWJMb\"]"));
        obj.put("transaction", new JSONObject());
        obj.put("block_id", "test_block_id");
        TransactionDetail.create(obj);
    });
}
 
Example 2
Source File: SignatureTest.java    From evt4j with MIT License 6 votes vote down vote up
@Test
@DisplayName("Can recover public key from signature")
void RecoverPublicKeyFromSignatureSuccessful() {
    Assertions.assertDoesNotThrow(() -> {
        String[] messages = new String[] { "helloworld", "foo", "bar", "baz", "evt", "evtjs", "everitoken.io" };
        PrivateKey key = PrivateKey.of("5JV1kctxPzU3BdRENgRyDcUWQSqqzeckzjKXJWSkBoxXmXUCqKB");

        Arrays.asList(messages).forEach(message -> {
            Signature sig = Signature.sign((message.getBytes()), key);
            PublicKey publicKey = Signature.recoverPublicKey(Utils.hash(message.getBytes()), sig);

            assertTrue(PublicKey.isValidPublicKey(publicKey.toString()));
            assertEquals(publicKey.toString(), key.toPublicKey().toString());
        });
    });
}
 
Example 3
Source File: SpecialResourceTypesRequiredParametersUtilTest.java    From multiapps-controller with Apache License 2.0 5 votes vote down vote up
@Test
void checkRequiredParametersForUserProvidedServiceWithRequiredParameter() {
    Map<String, Object> dummyParameters = new HashMap<>();
    dummyParameters.put("config", new Object());
    ResourceType resourceType = ResourceType.USER_PROVIDED_SERVICE;
    Assertions.assertDoesNotThrow(() -> SpecialResourceTypesRequiredParametersUtil.checkRequiredParameters(testServiceName,
                                                                                                           resourceType,
                                                                                                           dummyParameters));
}
 
Example 4
Source File: DynamodbStreamRecordTransformerTest.java    From aws-lambda-java-libs with Apache License 2.0 5 votes vote down vote up
@Test
public void testToStreamRecordV2WhenNewImageIsNull() {
    com.amazonaws.services.lambda.runtime.events.models.dynamodb.StreamRecord streamRecord = streamRecord_event.clone();
    streamRecord.setNewImage(null);

    Assertions.assertDoesNotThrow(() -> {
        DynamodbStreamRecordTransformer.toStreamRecordV2(streamRecord);
    });
}
 
Example 5
Source File: SignatureTest.java    From evt4j with MIT License 5 votes vote down vote up
@Test
@DisplayName("sign and signHash produces same result")
void signAndSignHash() {
    Assertions.assertDoesNotThrow(() -> {
        String message = "helloworldwhatnot";
        PrivateKey key = PrivateKey.of("5JV1kctxPzU3BdRENgRyDcUWQSqqzeckzjKXJWSkBoxXmXUCqKB");
        Signature sig = Signature.sign(message.getBytes(), key);
        Signature sig1 = Signature.signHash(Utils.hash(message.getBytes()), key);

        assertEquals(sig, sig1);
    });
}
 
Example 6
Source File: SignatureTest.java    From evt4j with MIT License 5 votes vote down vote up
@Test
@DisplayName("verify and verifyHash")
void verifyAndVerifyHash() {
    Assertions.assertDoesNotThrow(() -> {
        String message = "helloworld";
        PrivateKey key = PrivateKey.of("5JV1kctxPzU3BdRENgRyDcUWQSqqzeckzjKXJWSkBoxXmXUCqKB");
        Signature sig = Signature.sign(message.getBytes(), key);
        Signature sig1 = Signature.signHash(Utils.hash(message.getBytes()), key);

        boolean verifyResult = Signature.verify(message.getBytes(), sig1, key.toPublicKey());
        boolean verifyResult1 = Signature.verifyHash(Utils.hash(message.getBytes()), sig, key.toPublicKey());
        assertTrue(verifyResult, "Able to verify");
        assertTrue(verifyResult1, "Able to verify");
    });
}
 
Example 7
Source File: DependencyInjectionTest.java    From panda with Apache License 2.0 5 votes vote down vote up
@Test
void testInjector() {
    AtomicBoolean limiterCalled = new AtomicBoolean(false);

    Injector injector = DependencyInjection.createInjector(resources -> {
        resources.on(String.class).assignInstance(HELLO);

        resources.annotatedWith(CustomAnnotation.class).assignHandler((expected, annotation, injectorArgs) -> {
            return MAP.get(annotation.value());
        });

        resources.processAnnotatedType(CustomAnnotation.class, String.class, (customAnnotation, parameter, value, injectorArgs) -> {
            Assertions.assertArrayEquals(new Object[] { INJECTOR_ARG }, injectorArgs);

            if (value.length() > (HELLO_AUTOWIRED.length() - 2)) {
                limiterCalled.set(true);
            }

            return value;
        });
    });

    Assertions.assertDoesNotThrow(() -> {
        TestClass instance = injector.newInstance(TestClass.class);

        Method testTypeInvoke = ReflectionUtils.getMethod(TestClass.class, "testTypeInvoke", String.class).get();
        Assertions.assertEquals(HELLO, injector.invokeMethod(testTypeInvoke, instance));

        Method testAnnotationInvoke = ReflectionUtils.getMethod(TestClass.class, "testAnnotationInvoke", String.class).get();
        Assertions.assertEquals(HELLO_AUTOWIRED, injector.invokeMethod(testAnnotationInvoke, instance, INJECTOR_ARG));

        Method testForkedInjector = ReflectionUtils.getMethod(TestClass.class, "testForkedInjector", String.class, int.class).get();
        Assertions.assertEquals(DYNAMIC, (Integer) injector.fork(resources -> resources.on(int.class).assignInstance(DYNAMIC)).invokeMethod(testForkedInjector, instance));
    });

    Assertions.assertTrue(limiterCalled.get());
}
 
Example 8
Source File: DynamodbAttributeValueTransformerTest.java    From aws-lambda-java-libs with Apache License 2.0 5 votes vote down vote up
@Test
public void testToAttributeValueV2_DoesNotThrowWhenEmpty_L() {
    Assertions.assertDoesNotThrow(() ->
            DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withL())
    );
    Assertions.assertDoesNotThrow(() ->
            DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withL(Collections.emptyList()))
    );
}
 
Example 9
Source File: SpecialResourceTypesRequiredParametersUtilTest.java    From multiapps-controller with Apache License 2.0 5 votes vote down vote up
@Test
void checkRequiredParametersForManagedServiceWithRequiredParameter() {
    Map<String, Object> dummyParameters = new HashMap<>();
    dummyParameters.put("service", new Object());
    dummyParameters.put("service-plan", new Object());
    ResourceType resourceType = ResourceType.MANAGED_SERVICE;
    Assertions.assertDoesNotThrow(() -> SpecialResourceTypesRequiredParametersUtil.checkRequiredParameters(testServiceName,
                                                                                                           resourceType,
                                                                                                           dummyParameters));
}
 
Example 10
Source File: KeyProviderTest.java    From evt4j with MIT License 5 votes vote down vote up
@Test
@DisplayName("Single valid private key doesn't throw exception")
void initWithSingleValidPrivateKey() {
    Assertions.assertDoesNotThrow(() -> {
        KeyProvider.of(validPrivateKey);
    });
}
 
Example 11
Source File: PermissionTest.java    From evt4j with MIT License 5 votes vote down vote up
@Test
@DisplayName("Deserialize successful")
void deserialize() {
    Assertions.assertDoesNotThrow(() -> {
        Permission permission = Permission.ofRaw(JSONObject.parseObject(raw));
        Assertions.assertEquals(raw, JSON.toJSONString(permission));
        Assertions.assertEquals("issue", permission.getName());
        Assertions.assertEquals(1, permission.getThreshold());
        Assertions.assertEquals(1, permission.getAuthorizers().get(0).getWeight());
    });
}
 
Example 12
Source File: TestGeciReflectionTools.java    From javageci with Apache License 2.0 4 votes vote down vote up
@Test
@DisplayName("Does not throw an error when collecting methods from java.lang.Object")
public void collectsAllMethodsFromJavaLangObject() {
    Assertions.assertDoesNotThrow(() -> GeciReflectionTools.getAllMethodsSorted(java.lang.Object.class));
}
 
Example 13
Source File: JdbcUtilTest.java    From multiapps-controller with Apache License 2.0 4 votes vote down vote up
@Test
public void closeQuietlyStatementWithNull() {
    Statement statement = null;
    Assertions.assertDoesNotThrow(() -> JdbcUtil.closeQuietly(statement));
}
 
Example 14
Source File: TestGeciReflectionTools.java    From javageci with Apache License 2.0 4 votes vote down vote up
@Test
@DisplayName("Does not throw an error even when collecting fields from java.lang.Object")
public void collectsAllFieldsFromObjectClass() {
    Assertions.assertDoesNotThrow(() -> GeciReflectionTools.getAllFieldsSorted(java.lang.Object.class));
}
 
Example 15
Source File: TestGeciReflectionTools.java    From javageci with Apache License 2.0 4 votes vote down vote up
@Test
@DisplayName("Get field from superclass even if packages are not the same in the inheritance line.")
public void findInheritedFieldEvenIfPackageInheritanceIsBroken() {
    Assertions.assertDoesNotThrow(() -> GeciReflectionTools.getField(ChildClass.class, "inheritedFromGrandparentField"));
}
 
Example 16
Source File: JdbcUtilTest.java    From multiapps-controller with Apache License 2.0 4 votes vote down vote up
@Test
public void closeQuietlyResultSetWithNull() {
    ResultSet resultSet = null;
    Assertions.assertDoesNotThrow(() -> JdbcUtil.closeQuietly(resultSet));
}
 
Example 17
Source File: UsersRestControllerIT.java    From gaia with Mozilla Public License 2.0 4 votes vote down vote up
@Test
void users_shouldBeAccessible_forAdminUser() {
    Assertions.assertDoesNotThrow(() -> usersRestController.users());
}
 
Example 18
Source File: ExamplesLauncher.java    From panda with Apache License 2.0 4 votes vote down vote up
public static void launch(String directory, String file) {
    Assertions.assertDoesNotThrow(() -> {
        Application application = interpret(directory, file);
        launch(application);
    });
}
 
Example 19
Source File: RestRouterTest.java    From rest.vertx with Apache License 2.0 4 votes vote down vote up
@Test
void enableCors_specifyOrderBeforeAppendingRequestHandler() {
    Assertions.assertDoesNotThrow(() -> {
        RestRouter.enableCors(Router.router(vertx), "*", false, 1800, Collections.emptySet());
    });
}
 
Example 20
Source File: TeamsRestControllerIT.java    From gaia with Mozilla Public License 2.0 4 votes vote down vote up
@Test
@WithMockUser("Mary J")
void teams_shouldBeAccessible_forStandardUsers() {
    Assertions.assertDoesNotThrow(() -> teamsRestController.teams());
}