当前位置: 首页>>代码示例>>Java>>正文


Java Fail类代码示例

本文整理汇总了Java中org.assertj.core.api.Fail的典型用法代码示例。如果您正苦于以下问题:Java Fail类的具体用法?Java Fail怎么用?Java Fail使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Fail类属于org.assertj.core.api包,在下文中一共展示了Fail类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testTagPoolParser

import org.assertj.core.api.Fail; //导入依赖的package包/类
@Test
public void testTagPoolParser () throws BuenOjoCSVParserException {

	TagPoolCSVParser parser = new TagPoolCSVParser(new ByteArrayResource(csvString.getBytes(StandardCharsets.UTF_8)));
	Course course = new Course();
	course.setId(new Long(1000));
	try {
		List<Tag> tags = parser.parse(course);
		assertThat(tags).isNotNull().isNotEmpty();
		assertThat(tags.size()).isNotZero().isEqualTo(7);
		assertThat(tags.get(0).getNumber()).isEqualTo(1);
		assertThat(tags.get(1).getNumber()).isEqualTo(2);
		List<TagPool> tagPool = parser.parseTagPool();
		assertThat(tagPool).isNotNull().isNotEmpty();
		assertThat(tagPool.size()).isNotZero().isEqualTo(11);
		
	} catch (IOException e) {
	
		Fail.fail(e.getMessage());
	}
	
	
	
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:25,代码来源:TagPoolCSVParserTest.java

示例2: shouldNotAllowToCreateCustomerWithTheSameEmail

import org.assertj.core.api.Fail; //导入依赖的package包/类
@Test
public void shouldNotAllowToCreateCustomerWithTheSameEmail() throws Exception {
	//given
	String customerId = UUID.randomUUID().toString();
	String customerId2 = UUID.randomUUID().toString();
	customerCommandService.handle(new CreateCustomerCommand(customerId, "admin", "Abra", "Dab", "[email protected]", "77112233445"));

	try {
		//when
		//awaits for async unique email loads
		waitForAsyncUpdateFinish();
		customerCommandService.handle(new CreateCustomerCommand(customerId2, "admin", "Abra", "Dab", "[email protected]", "77112233445"));
		Fail.fail("exception expected");
	}
	catch (Exception e) {
		//then
		Assertions.assertThat(e).hasMessageContaining("[email protected]");
	}
}
 
开发者ID:bilu,项目名称:yaess,代码行数:20,代码来源:CustomerCommandServiceTest.java

示例3: shouldNotAllowToChangeEmailToExistingOne

import org.assertj.core.api.Fail; //导入依赖的package包/类
@Test
public void shouldNotAllowToChangeEmailToExistingOne() throws Exception {
	//given
	String customerId = UUID.randomUUID().toString();
	String customerId2 = UUID.randomUUID().toString();
	String customerId3 = UUID.randomUUID().toString();
	customerCommandService.handle(new CreateCustomerCommand(customerId, "admin", "Abra", "Dab", "[email protected]", "77112233445"));
	customerCommandService.handle(new CreateCustomerCommand(customerId2, "admin", "Abra", "Dab", "[email protected]", "77112233445"));
	customerCommandService.handle(new CreateCustomerCommand(customerId3, "admin", "Abra", "Dab", "[email protected]", "77112233445"));
	Assertions.assertThat(customerRepository.exists(new RootAggregateId(customerId))).isTrue();
	Assertions.assertThat(customerRepository.exists(new RootAggregateId(customerId2))).isTrue();
	Assertions.assertThat(customerRepository.exists(new RootAggregateId(customerId3))).isTrue();

	try {
		//when
		//awaits for async unique email loads
		waitForAsyncUpdateFinish();
		customerCommandService.handle(new ChangeCustomerEmailCommand(customerId3, "admin", "[email protected]"));
		Fail.fail("exception expected");
	}
	catch (Exception e) {
		//then
		Assertions.assertThat(e).hasMessageContaining("[email protected]");
	}
}
 
开发者ID:bilu,项目名称:yaess,代码行数:26,代码来源:CustomerCommandServiceTest.java

示例4: shouldNotAllowToChangeEmailToExistingOneWithMultipleEmailChange

import org.assertj.core.api.Fail; //导入依赖的package包/类
@Test
public void shouldNotAllowToChangeEmailToExistingOneWithMultipleEmailChange() throws Exception {
	//given
	String customerId = UUID.randomUUID().toString();
	String customerId2 = UUID.randomUUID().toString();
	customerCommandService.handle(new CreateCustomerCommand(customerId, "admin", "Abra", "Dab", "[email protected]", "77112233445"));
	customerCommandService.handle(new CreateCustomerCommand(customerId2, "admin", "Abra", "Dab", "[email protected]", "77112233445"));
	Assertions.assertThat(customerRepository.exists(new RootAggregateId(customerId))).isTrue();
	Assertions.assertThat(customerRepository.exists(new RootAggregateId(customerId2))).isTrue();
	customerCommandService.handle(new ChangeCustomerEmailCommand(customerId2, "admin", "[email protected]"));

	try {
		//when
		//awaits for async unique email loads
		waitForAsyncUpdateFinish();
		customerCommandService.handle(new ChangeCustomerEmailCommand(customerId, "admin", "[email protected]"));
		Fail.fail("exception expected");
	}
	catch (Exception e) {
		//then
		Assertions.assertThat(e).hasMessageContaining("[email protected]");
	}
}
 
开发者ID:bilu,项目名称:yaess,代码行数:24,代码来源:CustomerCommandServiceTest.java

示例5: shouldConcurrentSaveWhenModificationMadeThrowException

import org.assertj.core.api.Fail; //导入依赖的package包/类
@Test
public void shouldConcurrentSaveWhenModificationMadeThrowException() throws Exception {
	//given
	Customer customer = new Customer(UUID.randomUUID().toString(), "Jake", "Blue", "[email protected]", "77112233445", "admin");
	customerRepository.save(customer);
	Customer concurrentCustomer1 = customerRepository.get(customer.id());
	Customer concurrentCustomer2 = customerRepository.get(customer.id());

	//when
	concurrentCustomer1.changeFirstName("Jake2", "admin");
	customerRepository.save(concurrentCustomer1);

	try {
		customerRepository.save(concurrentCustomer2);
		Fail.fail("Exception expected");
	}
	catch (Exception e) {
		Assertions.assertThat(e).isInstanceOf(ConcurrentModificationException.class);
	}

	//then
	//No exception thrown
}
 
开发者ID:bilu,项目名称:yaess,代码行数:24,代码来源:EventStoreRepositoryTest.java

示例6: shouldBeImpossibleToRecreateCustomerWithIncorrectRootAggregateId

import org.assertj.core.api.Fail; //导入依赖的package包/类
@Test
public void shouldBeImpossibleToRecreateCustomerWithIncorrectRootAggregateId() throws Exception {
	//given
	RootAggregateId RootAggregateId = new RootAggregateId();
	RootAggregateId RootAggregateId2 = new RootAggregateId();
	Event event1 = new CustomerCreatedV3Event(RootAggregateId, "test newName 1", "test surname 1", "[email protected]", "77112233445", LocalDateTime.now(), "admin");
	Event event2 = new CustomerRenamedEvent(RootAggregateId2, "test newName 2", LocalDateTime.now(), "admin");
	List<Event> customerEvents = Arrays.asList(event1, event2);

	//when
	try {
		new Customer(customerEvents);
		Fail.fail("Exception expected");
	}
	catch (Exception e) {
		//then
		Assertions.assertThat(e)
			.isInstanceOf(ContractBrokenException.class)
			.hasMessageContaining(RootAggregateId.toString())
			.hasMessageContaining(RootAggregateId2.toString());

	}

}
 
开发者ID:bilu,项目名称:yaess,代码行数:25,代码来源:CustomerTest.java

示例7: queryMapKeysMustBeStrings

import org.assertj.core.api.Fail; //导入依赖的package包/类
@Test
public void queryMapKeysMustBeStrings() throws Exception {
  server.enqueue(new MockResponse());

  TestInterface api = new TestInterfaceBuilder().target("http://localhost:" + server.getPort());

  Map<Object, String> queryMap = new LinkedHashMap<Object, String>();
  queryMap.put(Integer.valueOf(42), "alice");

  try {
    api.queryMap((Map) queryMap);
    Fail.failBecauseExceptionWasNotThrown(IllegalStateException.class);
  } catch (IllegalStateException ex) {
    assertThat(ex).hasMessage("QueryMap key must be a String: 42");
  }
}
 
开发者ID:wenwu315,项目名称:XXXX,代码行数:17,代码来源:FeignTest.java

示例8: loadConfiguration

import org.assertj.core.api.Fail; //导入依赖的package包/类
private void loadConfiguration() {
    Properties sysProps = System.getProperties();
    String configFileName = sysProps.getProperty("test.config.filename");

    if (StringUtils.isEmpty(configFileName)) {
        configFileName = defaultConfigurationFileName;
    }

    try {
        AllConfiguration = new DefaultConfigurationBuilder(configFileName).getConfiguration();
        ((HierarchicalConfiguration) AllConfiguration).setExpressionEngine(new XPathExpressionEngine());
    } catch (Exception e) {
        Fail.fail("failed to read config file", e);
        log.error("Failed to read config file", e);
    }
}
 
开发者ID:AgileTestingFramework,项目名称:atf-toolbox-java,代码行数:17,代码来源:ConfigurationManager.java

示例9: checkIfFileOpened

import org.assertj.core.api.Fail; //导入依赖的package包/类
/**
 * Checks if the file opened correctly
 * 
 * @param states
 *            the different states of the region
 */
public void checkIfFileOpened(String... states) {

	Region match = null;

	try {

		// check if file opened
		SikuliXAutomation.setSearchRegion(SCREEN);
		match = findMultipleStateRegion(DEFAULT_TIMEOUT, states);

		// close editor
		match.click();
		closeFocusedProgram();

	} catch (FindFailed e) {
		Fail.fail("File did not open.", e);
	}

}
 
开发者ID:aguelle,项目名称:MIDI-Automator,代码行数:26,代码来源:SikuliXGUIAutomations.java

示例10: checkIfFileNotOpened

import org.assertj.core.api.Fail; //导入依赖的package包/类
/**
 * Checks if the file did not open.
 * 
 * @param states
 *            the different states of the region
 */
public void checkIfFileNotOpened(String... states) {

	Region match = null;

	try {

		// check if file opened
		SikuliXAutomation.setSearchRegion(SCREEN);
		match = findMultipleStateRegion(DEFAULT_TIMEOUT, states);

		// close editor
		match.click();
		closeFocusedProgram();
		Fail.fail("File did open.");

	} catch (FindFailed e) {

	}
}
 
开发者ID:aguelle,项目名称:MIDI-Automator,代码行数:26,代码来源:SikuliXGUIAutomations.java

示例11: assertMultipleOutputValues

import org.assertj.core.api.Fail; //导入依赖的package包/类
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");
  }
}
 
开发者ID:camunda,项目名称:camunda-engine-dmn,代码行数:24,代码来源:DmnDecisionResultTest.java

示例12: assertMultipleOutputValues

import org.assertj.core.api.Fail; //导入依赖的package包/类
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");
  }
}
 
开发者ID:camunda,项目名称:camunda-engine-dmn,代码行数:24,代码来源:DmnDecisionTableResultTest.java

示例13: testAwsV4SignatureBadIdentity

import org.assertj.core.api.Fail; //导入依赖的package包/类
@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");
    }
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:21,代码来源:AwsSdkTest.java

示例14: testAwsV4SignatureBadCredential

import org.assertj.core.api.Fail; //导入依赖的package包/类
@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");
    }
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:22,代码来源:AwsSdkTest.java

示例15: testUpdateBlobXmlAcls

import org.assertj.core.api.Fail; //导入依赖的package包/类
@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");
    }
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:27,代码来源:AwsSdkTest.java


注:本文中的org.assertj.core.api.Fail类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。