org.assertj.core.api.Fail Java Examples

The following examples show how to use org.assertj.core.api.Fail. 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: DmnDecisionResultTest.java    From camunda-engine-dmn with Apache License 2.0 6 votes vote down vote up
protected void assertMultipleOutputValues(DmnDecisionResultEntries result) {
  assertThat(result.size()).isEqualTo(2);

  String value = (String) result.get("firstOutput");
  assertThat(value).isEqualTo("multipleValues1");

  value = (String) result.get("secondOutput");
  assertThat(value).isEqualTo("multipleValues2");

  value = result.getFirstEntry();
  assertThat(value).isEqualTo("multipleValues1");

  try {
    result.getSingleEntry();
    Fail.failBecauseExceptionWasNotThrown(DmnDecisionResultException.class);
  }
  catch (DmnDecisionResultException e) {
    assertThat(e)
      .hasMessageStartingWith("DMN-01010")
      .hasMessageContaining("multipleValues1")
      .hasMessageContaining("multipleValues2");
  }
}
 
Example #2
Source File: DmnDecisionTableResultTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void assertMultipleOutputValues(DmnDecisionRuleResult decisionRuleResult) {
  assertThat(decisionRuleResult.size()).isEqualTo(2);

  String value = (String) decisionRuleResult.get("firstOutput");
  assertThat(value).isEqualTo("multipleValues1");

  value = (String) decisionRuleResult.get("secondOutput");
  assertThat(value).isEqualTo("multipleValues2");

  value = decisionRuleResult.getFirstEntry();
  assertThat(value).isEqualTo("multipleValues1");

  try {
    decisionRuleResult.getSingleEntry();
    Fail.failBecauseExceptionWasNotThrown(DmnDecisionResultException.class);
  }
  catch (DmnDecisionResultException e) {
    assertThat(e)
      .hasMessageStartingWith("DMN-01007")
      .hasMessageContaining("multipleValues1")
      .hasMessageContaining("multipleValues2");
  }
}
 
Example #3
Source File: DmnDecisionResultTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void assertMultipleOutputValues(DmnDecisionResultEntries result) {
  assertThat(result.size()).isEqualTo(2);

  String value = (String) result.get("firstOutput");
  assertThat(value).isEqualTo("multipleValues1");

  value = (String) result.get("secondOutput");
  assertThat(value).isEqualTo("multipleValues2");

  value = result.getFirstEntry();
  assertThat(value).isEqualTo("multipleValues1");

  try {
    result.getSingleEntry();
    Fail.failBecauseExceptionWasNotThrown(DmnDecisionResultException.class);
  }
  catch (DmnDecisionResultException e) {
    assertThat(e)
      .hasMessageStartingWith("DMN-01010")
      .hasMessageContaining("multipleValues1")
      .hasMessageContaining("multipleValues2");
  }
}
 
Example #4
Source File: TestCaseWithTargetTest.java    From RDFUnit with Apache License 2.0 6 votes vote down vote up
@Test
public void test() {

    TestCase innerTestCAse = Mockito.mock(TestCase.class);
    when(innerTestCAse.getSparqlWhere()).thenReturn(sparqlQuery);

    TestCase testCaseWithTarget = TestCaseWithTarget.builder()
            .testCase(innerTestCAse)
            .target(target)
            .filterSparql(" ?this <http://example.cpm/p> ?value .")
            .build();

    String finalSparql = PrefixNSService.getSparqlPrefixDecl() + testCaseWithTarget.getSparqlWhere();

    assertThat(finalSparql)
            .contains(target.getPattern());

    try {
        QueryFactory.create(finalSparql);
    } catch (Exception e) {
        Fail.fail("Failed sparql query:\n" + finalSparql, e);
    }

}
 
Example #5
Source File: AwsSdkTest.java    From s3proxy with Apache License 2.0 6 votes vote down vote up
@Test
public void testBlobRemove() throws Exception {
    String blobName = "blob";
    ObjectMetadata metadata = new ObjectMetadata();
    metadata.setContentLength(BYTE_SOURCE.size());
    client.putObject(containerName, blobName, BYTE_SOURCE.openStream(),
            metadata);
    assertThat(client.getObjectMetadata(containerName, blobName))
            .isNotNull();

    client.deleteObject(containerName, blobName);
    try {
        client.getObjectMetadata(containerName, blobName);
        Fail.failBecauseExceptionWasNotThrown(AmazonS3Exception.class);
    } catch (AmazonS3Exception e) {
        assertThat(e.getErrorCode()).isEqualTo("404 Not Found");
    }

    client.deleteObject(containerName, blobName);
}
 
Example #6
Source File: AwsSdkTest.java    From s3proxy with Apache License 2.0 6 votes vote down vote up
@Test
public void testPartNumberMarker() throws Exception {
    String blobName = "foo";
    InitiateMultipartUploadResult result = client.initiateMultipartUpload(
            new InitiateMultipartUploadRequest(containerName, blobName));
    ListPartsRequest request = new ListPartsRequest(containerName,
            blobName, result.getUploadId());

    client.listParts(request.withPartNumberMarker(0));

    try {
        client.listParts(request.withPartNumberMarker(1));
        Fail.failBecauseExceptionWasNotThrown(AmazonS3Exception.class);
    } catch (AmazonS3Exception e) {
        assertThat(e.getErrorCode()).isEqualTo("NotImplemented");
    }
}
 
Example #7
Source File: AwsSdkTest.java    From s3proxy with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateBlobXmlAcls() throws Exception {
    assumeTrue(!Quirks.NO_BLOB_ACCESS_CONTROL.contains(blobStoreType));
    String blobName = "testUpdateBlobXmlAcls-blob";
    ObjectMetadata metadata = new ObjectMetadata();
    metadata.setContentLength(BYTE_SOURCE.size());
    client.putObject(containerName, blobName, BYTE_SOURCE.openStream(),
            metadata);
    AccessControlList acl = client.getObjectAcl(containerName, blobName);

    acl.grantPermission(GroupGrantee.AllUsers, Permission.Read);
    client.setObjectAcl(containerName, blobName, acl);
    assertThat(client.getObjectAcl(containerName, blobName)).isEqualTo(acl);

    acl.revokeAllPermissions(GroupGrantee.AllUsers);
    client.setObjectAcl(containerName, blobName, acl);
    assertThat(client.getObjectAcl(containerName, blobName)).isEqualTo(acl);

    acl.grantPermission(GroupGrantee.AllUsers, Permission.Write);
    try {
        client.setObjectAcl(containerName, blobName, acl);
        Fail.failBecauseExceptionWasNotThrown(AmazonS3Exception.class);
    } catch (AmazonS3Exception e) {
        assertThat(e.getErrorCode()).isEqualTo("NotImplemented");
    }
}
 
Example #8
Source File: ConnectionLoggerRegistryTest.java    From ditto with Eclipse Public License 2.0 6 votes vote down vote up
private void addLogEntriesUntilMaxSizeIsExceeded(final ConnectionLogger logger) throws InterruptedException {
    final long maxSize = TestConstants.MONITORING_CONFIG.logger().maxLogSizeInBytes();
    final int maxFailureLogs = TestConstants.MONITORING_CONFIG.logger().failureCapacity();
    int currentFailureLogs = 0;

    while (getCurrentLogsSize(logger) < maxSize) {
        logger.failure(randomInfoProvider());
        TimeUnit.MILLISECONDS.sleep(1); // ensure different timestamps to make ordering assertion stable

        if (++currentFailureLogs > maxFailureLogs) {
            Fail.fail("Breaking the while loop as I can't create enough failure logs to trigger the "
            + "max logs size. Review the logger config and find fitting config values for the maxLogSizeInBytes "
            + "and the failure capacity.");
        }
    }
}
 
Example #9
Source File: DmnDecisionTableResultTest.java    From camunda-engine-dmn with Apache License 2.0 6 votes vote down vote up
protected void assertMultipleOutputValues(DmnDecisionRuleResult decisionRuleResult) {
  assertThat(decisionRuleResult.size()).isEqualTo(2);

  String value = (String) decisionRuleResult.get("firstOutput");
  assertThat(value).isEqualTo("multipleValues1");

  value = (String) decisionRuleResult.get("secondOutput");
  assertThat(value).isEqualTo("multipleValues2");

  value = decisionRuleResult.getFirstEntry();
  assertThat(value).isEqualTo("multipleValues1");

  try {
    decisionRuleResult.getSingleEntry();
    Fail.failBecauseExceptionWasNotThrown(DmnDecisionResultException.class);
  }
  catch (DmnDecisionResultException e) {
    assertThat(e)
      .hasMessageStartingWith("DMN-01007")
      .hasMessageContaining("multipleValues1")
      .hasMessageContaining("multipleValues2");
  }
}
 
Example #10
Source File: AwsSdkTest.java    From s3proxy with Apache License 2.0 6 votes vote down vote up
@Test
public void testAwsV4SignatureBadIdentity() throws Exception {
    client = AmazonS3ClientBuilder.standard()
            .withCredentials(new AWSStaticCredentialsProvider(
                    new BasicAWSCredentials(
                            "bad-access-key", awsCreds.getAWSSecretKey())))
            .withEndpointConfiguration(s3EndpointConfig)
            .build();

    ObjectMetadata metadata = new ObjectMetadata();
    metadata.setContentLength(BYTE_SOURCE.size());

    try {
        client.putObject(containerName, "foo",
                BYTE_SOURCE.openStream(), metadata);
        Fail.failBecauseExceptionWasNotThrown(AmazonS3Exception.class);
    } catch (AmazonS3Exception e) {
        assertThat(e.getErrorCode()).isEqualTo("InvalidAccessKeyId");
    }
}
 
Example #11
Source File: AwsSdkTest.java    From s3proxy with Apache License 2.0 6 votes vote down vote up
@Test
public void testAwsV4SignatureBadCredential() throws Exception {
    client = AmazonS3ClientBuilder.standard()
            .withCredentials(new AWSStaticCredentialsProvider(
                    new BasicAWSCredentials(
                            awsCreds.getAWSAccessKeyId(),
                            "bad-secret-key")))
            .withEndpointConfiguration(s3EndpointConfig)
            .build();

    ObjectMetadata metadata = new ObjectMetadata();
    metadata.setContentLength(BYTE_SOURCE.size());

    try {
        client.putObject(containerName, "foo",
                BYTE_SOURCE.openStream(), metadata);
        Fail.failBecauseExceptionWasNotThrown(AmazonS3Exception.class);
    } catch (AmazonS3Exception e) {
        assertThat(e.getErrorCode()).isEqualTo("SignatureDoesNotMatch");
    }
}
 
Example #12
Source File: JcloudsBucketsLiveTest.java    From s3proxy with Apache License 2.0 5 votes vote down vote up
@Override
@Test
public void testBucketPayer() throws Exception {
    try {
        super.testBucketPayer();
        Fail.failBecauseExceptionWasNotThrown(AWSResponseException.class);
    } catch (AWSResponseException are) {
        assertThat(are.getError().getCode()).isEqualTo("NotImplemented");
        throw new SkipException("bucket payer not supported", are);
    }
}
 
Example #13
Source File: AwsSdkTest.java    From s3proxy with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeleteMultipleObjectsEmpty() throws Exception {
    DeleteObjectsRequest request = new DeleteObjectsRequest(containerName)
            .withKeys();

    try {
        client.deleteObjects(request);
        Fail.failBecauseExceptionWasNotThrown(AmazonS3Exception.class);
    } catch (AmazonS3Exception e) {
        assertThat(e.getErrorCode()).isEqualTo("MalformedXML");
    }
}
 
Example #14
Source File: AwsSdkTest.java    From s3proxy with Apache License 2.0 5 votes vote down vote up
@Test
public void testContainerExists() throws Exception {
    client.headBucket(new HeadBucketRequest(containerName));
    try {
        client.headBucket(new HeadBucketRequest(
                createRandomContainerName()));
        Fail.failBecauseExceptionWasNotThrown(AmazonS3Exception.class);
    } catch (AmazonS3Exception e) {
        assertThat(e.getErrorCode()).isEqualTo("404 Not Found");
    }
}
 
Example #15
Source File: AwsSdkTest.java    From s3proxy with Apache License 2.0 5 votes vote down vote up
@Test
public void testContainerCreateDelete() throws Exception {
    String containerName2 = createRandomContainerName();
    client.createBucket(containerName2);
    try {
        client.createBucket(containerName2);
        client.deleteBucket(containerName2);
        Fail.failBecauseExceptionWasNotThrown(AmazonS3Exception.class);
    } catch (AmazonS3Exception e) {
        assertThat(e.getErrorCode()).isEqualTo("BucketAlreadyOwnedByYou");
    }
}
 
Example #16
Source File: DefaultContractTest.java    From feign with Apache License 2.0 5 votes vote down vote up
@Test
public void onlyOneHeaderMapAnnotationPermitted() throws Exception {
  try {
    parseAndValidateMetadata(HeaderMapInterface.class, "multipleHeaderMap", Map.class, Map.class);
    Fail.failBecauseExceptionWasNotThrown(IllegalStateException.class);
  } catch (final IllegalStateException ex) {
    assertThat(ex).hasMessage("HeaderMap annotation was present on multiple parameters.");
  }
}
 
Example #17
Source File: DefaultContractTest.java    From feign with Apache License 2.0 5 votes vote down vote up
@Test
public void queryMapKeysMustBeStrings() throws Exception {
  try {
    parseAndValidateMetadata(QueryMapTestInterface.class, "nonStringKeyQueryMap", Map.class);
    Fail.failBecauseExceptionWasNotThrown(IllegalStateException.class);
  } catch (final IllegalStateException ex) {
    assertThat(ex).hasMessage("QueryMap key must be a String: Integer");
  }
}
 
Example #18
Source File: DefaultContractTest.java    From feign with Apache License 2.0 5 votes vote down vote up
@Test
public void onlyOneQueryMapAnnotationPermitted() throws Exception {
  try {
    parseAndValidateMetadata(QueryMapTestInterface.class, "multipleQueryMap", Map.class,
        Map.class);
    Fail.failBecauseExceptionWasNotThrown(IllegalStateException.class);
  } catch (final IllegalStateException ex) {
    assertThat(ex).hasMessage("QueryMap annotation was present on multiple parameters.");
  }
}
 
Example #19
Source File: DefaultContractTest.java    From feign with Apache License 2.0 5 votes vote down vote up
@Test
public void bodyParamsAndformParam() throws Exception {
  thrown.expect(IllegalStateException.class);
  thrown.expectMessage("Body parameters cannot be used with form parameters.");

  parseAndValidateMetadata(FormParams.class,
      "bodyParamsAndformParam", String.class, String.class);
  Fail.failBecauseExceptionWasNotThrown(IllegalStateException.class);
}
 
Example #20
Source File: DefaultContractTest.java    From feign with Apache License 2.0 5 votes vote down vote up
@Test
public void formParamAndBodyParams() throws Exception {
  thrown.expect(IllegalStateException.class);
  thrown.expectMessage("Body parameters cannot be used with form parameters.");

  parseAndValidateMetadata(FormParams.class,
      "formParamAndBodyParams", String.class, String.class);
  Fail.failBecauseExceptionWasNotThrown(IllegalStateException.class);
}
 
Example #21
Source File: TransactionPluginTest.java    From seed with Mozilla Public License 2.0 5 votes vote down vote up
@Test
public void isTransactionalTest() {
    try {
        Assertions.assertThat(
                pluginUnderTest.isTransactional(this.getClass().getDeclaredMethod("testTransactional"))).isTrue();
    } catch (SecurityException | NoSuchMethodException e) {
        Fail.fail(e.getMessage());
    }
}
 
Example #22
Source File: JcloudsBucketsLiveTest.java    From s3proxy with Apache License 2.0 5 votes vote down vote up
@Override
@Test
public void testBucketLogging() throws Exception {
    try {
        super.testBucketLogging();
        Fail.failBecauseExceptionWasNotThrown(AWSResponseException.class);
    } catch (AWSResponseException are) {
        assertThat(are.getError().getCode()).isEqualTo("NotImplemented");
        throw new SkipException("bucket logging not supported", are);
    }
}
 
Example #23
Source File: AwsSdkTest.java    From s3proxy with Apache License 2.0 5 votes vote down vote up
@Test
public void testContainerDelete() throws Exception {
    client.headBucket(new HeadBucketRequest(containerName));
    client.deleteBucket(containerName);
    try {
        client.headBucket(new HeadBucketRequest(containerName));
        Fail.failBecauseExceptionWasNotThrown(AmazonS3Exception.class);
    } catch (AmazonS3Exception e) {
        assertThat(e.getErrorCode()).isEqualTo("404 Not Found");
    }
}
 
Example #24
Source File: JcloudsBucketsLiveTest.java    From s3proxy with Apache License 2.0 5 votes vote down vote up
@Override
@Test
public void testUpdateBucketACL() throws Exception {
    try {
        super.testUpdateBucketACL();
        Fail.failBecauseExceptionWasNotThrown(AWSResponseException.class);
    } catch (AWSResponseException are) {
        assertThat(are.getError().getCode()).isEqualTo("NotImplemented");
        throw new SkipException("XML ACLs not supported", are);
    }
}
 
Example #25
Source File: ReadOnlyBlobStoreTest.java    From s3proxy with Apache License 2.0 5 votes vote down vote up
@Test
public void testPutBlobOptions() throws Exception {
    try {
        readOnlyBlobStore.putBlob(containerName, null, new PutOptions());
        Fail.failBecauseExceptionWasNotThrown(
                UnsupportedOperationException.class);
    } catch (UnsupportedOperationException ne) {
        // expected
    }
}
 
Example #26
Source File: ReadOnlyBlobStoreTest.java    From s3proxy with Apache License 2.0 5 votes vote down vote up
@Test
public void testPutBlob() throws Exception {
    try {
        readOnlyBlobStore.putBlob(containerName, null);
        Fail.failBecauseExceptionWasNotThrown(
                UnsupportedOperationException.class);
    } catch (UnsupportedOperationException ne) {
        // expected
    }
}
 
Example #27
Source File: JcloudsS3ClientLiveTest.java    From s3proxy with Apache License 2.0 5 votes vote down vote up
@Override
@Test
public void testUpdateObjectACL() throws InterruptedException,
        ExecutionException, TimeoutException, IOException {
    try {
        super.testUpdateObjectACL();
        Fail.failBecauseExceptionWasNotThrown(AWSResponseException.class);
    } catch (AWSResponseException are) {
        assertThat(are.getError().getCode()).isEqualTo("NotImplemented");
        throw new SkipException("XML ACLs not supported", are);
    }
}
 
Example #28
Source File: JcloudsS3ClientLiveTest.java    From s3proxy with Apache License 2.0 5 votes vote down vote up
@Override
@Test
public void testPublicWriteOnObject() throws InterruptedException,
        ExecutionException, TimeoutException, IOException {
    try {
        super.testPublicWriteOnObject();
        Fail.failBecauseExceptionWasNotThrown(AWSResponseException.class);
    } catch (AWSResponseException are) {
        assertThat(are.getError().getCode()).isEqualTo("NotImplemented");
        throw new SkipException("public-read-write-acl not supported", are);
    }
}
 
Example #29
Source File: AwsSdkTest.java    From s3proxy with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnknownParameter() throws Exception {
    try {
        client.setBucketLoggingConfiguration(
                new SetBucketLoggingConfigurationRequest(
                        containerName, new BucketLoggingConfiguration()));
        Fail.failBecauseExceptionWasNotThrown(AmazonS3Exception.class);
    } catch (AmazonS3Exception e) {
        assertThat(e.getErrorCode()).isEqualTo("NotImplemented");
    }
}
 
Example #30
Source File: AwsSdkTest.java    From s3proxy with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetBucketPolicy() throws Exception {
    try {
        client.getBucketPolicy(containerName);
        Fail.failBecauseExceptionWasNotThrown(AmazonS3Exception.class);
    } catch (AmazonS3Exception e) {
        assertThat(e.getErrorCode()).isEqualTo("NoSuchPolicy");
    }
}