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


Java Fail.fail方法代码示例

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


在下文中一共展示了Fail.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: 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

示例8: 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

示例9: 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

示例10: test

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

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

    TestCase testCaseWithTarget = TestCaseWithTarget.builder()
            .testCase(innerTestCAse)
            .target(target)
            .filterSpqrql(" ?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);
    }

}
 
开发者ID:AKSW,项目名称:RDFUnit,代码行数:25,代码来源:TestCaseWithTargetTest.java

示例11: testTagCircleParse

import org.assertj.core.api.Fail; //导入方法依赖的package包/类
@Test
public void testTagCircleParse() {
	
	InputStream in = new ByteArrayInputStream(csvString.getBytes(StandardCharsets.UTF_8));
	TagCircleCSVParser parser = new TagCircleCSVParser(in);
	List<TagCircle> list = null;
	try {
		list = parser.parse();
	}
	catch (Exception e) {
		assertThat(e).isInstanceOf(IOException.class);
		Fail.fail(e.getMessage());
	}
	assertThat(list).isNotEmpty();
	assertThat(list).isNotNull();
	assertThat(list.size()).isEqualTo(2);
	assertThat(list.get(0).getNumber()).isEqualTo(0);
	assertThat(list.get(0).getX()).isEqualTo(431);
	assertThat(list.get(0).getY()).isEqualTo(197);
	assertThat(list.get(0).getRadioPx()).isCloseTo(73.72f, Offset.offset(0.1f));
	
	assertThat(list.get(1).getNumber()).isEqualTo(1);
	
	assertThat(list.get(1).getX()).isEqualTo(344);
	assertThat(list.get(1).getY()).isEqualTo(317);
	assertThat(list.get(1).getRadioPx()).isCloseTo(29.49f, Offset.offset(0.1f));
	

}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:30,代码来源:TagCircleCSVParserTest.java

示例12: thenThrowNoException

import org.assertj.core.api.Fail; //导入方法依赖的package包/类
public SELF_TYPE thenThrowNoException() {

		if (exceptionThrownOptional.isPresent()) {
			Exception e = exceptionThrownOptional.get();
			// TODO [bilu] 06.11.17 more detailed stack
			Fail.fail("Expected no exception, found exception of class " + e.getClass() + " with message " + e.getMessage() + ". Caused by " + e.getCause());
		}
		return self();
	}
 
开发者ID:bilu,项目名称:yaess,代码行数:10,代码来源:BDDTest.java

示例13: shouldNotAllowConcurrentModification

import org.assertj.core.api.Fail; //导入方法依赖的package包/类
@Test
public void shouldNotAllowConcurrentModification() throws Exception {
	//given
	List<Event> initialEvents = Arrays.asList(
		new CustomerCreatedV2Event(customerId, "john", "Doe", "[email protected]", "88112233445", LocalDateTime.now(), "admin"),
		new CustomerRenamedEvent(customerId, "zmiana1", LocalDateTime.now(), "admin"),
		new CustomerRenamedEvent(customerId, "zmiana2", LocalDateTime.now(), "admin")
	);
	List<Event> anotherEvents = Arrays.asList(
		new CustomerDeletedEvent(customerId, LocalDateTime.now(), "admin")
	);

	store.appendEvents(customerId, rootAggregateClass, initialEvents, 0);
	List<Event> customerEvents1 = store.loadEvents(customerId, rootAggregateClass);
	List<Event> customerEvents2 = store.loadEvents(customerId, rootAggregateClass);

	//when
	store.appendEvents(customerId, rootAggregateClass, anotherEvents, customerEvents1.size() + anotherEvents.size());
	try {
		store.appendEvents(customerId, rootAggregateClass, anotherEvents, customerEvents2.size());
		Fail.fail("Exception expected");
	}
	catch (Exception e) {
		Assertions.assertThat(e)
			.isInstanceOf(ConcurrentModificationException.class)
			.hasMessageContaining(customerId.toString());
	}
}
 
开发者ID:bilu,项目名称:yaess,代码行数:29,代码来源:InMemoryEventStoreTest.java

示例14: testDeleteNonExisting

import org.assertj.core.api.Fail; //导入方法依赖的package包/类
public void testDeleteNonExisting() {
    final SimpleTestEntity ent = new SimpleTestEntity();
    ent.setId(Long.MAX_VALUE);
    try {
        dao.delete(ent);
        Fail.fail("Exception should have been thrown!");
    } catch (final Throwable t) {
        final boolean causedBy = Throwables.isCausedByType(t, EmptyResultDataAccessException.class);
        if (!causedBy) {
            throw Err.process(t);
        }
    }
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:14,代码来源:SimpleTestDaoTest.java

示例15: testWriteAndRead

import org.assertj.core.api.Fail; //导入方法依赖的package包/类
@Transactional
public void testWriteAndRead() {
    final SimpleTestEntity ent1 = new SimpleTestEntity();
    ent1.setName("one");

    Assertions.assertThat(dao.isEmpty()).isTrue();
    dao.save(ent1);
    Assertions.assertThat(dao.isEmpty()).isFalse();
    ent1.setName("two");
    dao.save(ent1);

    final SimpleTestEntity ent2 = new SimpleTestEntity();
    ent2.setName("999");
    dao.save(ent2);

    List<SimpleTestEntity> all = dao.findAll();
    Assertions.assertThat(all.size()).isEqualTo(2);
    for (final SimpleTestEntity e : all) {
        if (e.getId().equals(ent1.getId())) {
            Assertions.assertThat(e.getName()).isEqualTo(ent1.getName());
        } else if (e.getId().equals(ent2.getId())) {
            Assertions.assertThat(e.getName()).isEqualTo(ent2.getName());
        } else {
            Fail.fail("Unbekannte Entity: " + e.getId());
        }
    }

    final SimpleTestEntity example = new SimpleTestEntity();
    example.setName("two");
    all = dao.findAll(example);
    Assertions.assertThat(all.size()).isEqualTo(1);
    Assertions.assertThat(all.get(0).getName()).isEqualTo("two");
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:34,代码来源:SimpleTestDaoTest.java


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