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


Java BDDAssertions类代码示例

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


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

示例1: saveShouldMapCorrectly

import org.assertj.core.api.BDDAssertions; //导入依赖的package包/类
@Test
public void saveShouldMapCorrectly() throws Exception {
    Customer customer = new Customer(null, "first", "last", "[email protected]");
    Customer saved = this.testEntityManager.persistFlushFind(customer);

    BDDAssertions.then(saved.getId()).isNotNull();

    BDDAssertions.then(saved.getFirstName()).isEqualToIgnoringCase("first");
    BDDAssertions.then(saved.getFirstName()).isNotBlank();

    BDDAssertions.then(saved.getLastName()).isEqualToIgnoringCase("last");
    BDDAssertions.then(saved.getLastName()).isNotBlank();

    BDDAssertions.then(saved.getEmail()).isEqualToIgnoringCase("[email protected]");
    BDDAssertions.then(saved.getLastName()).isNotBlank();

}
 
开发者ID:applied-continuous-delivery-livelessons,项目名称:cdct,代码行数:18,代码来源:CustomerRepositoryTest.java

示例2: repositorySaveShouldMapCorrectly

import org.assertj.core.api.BDDAssertions; //导入依赖的package包/类
@Test
public void repositorySaveShouldMapCorrectly() {

    Customer customer = new Customer(null, "first", "last", "[email protected]");
    Customer saved = this.repository.save(customer);

    BDDAssertions.then(saved.getId()).isNotNull();

    BDDAssertions.then(saved.getFirstName()).isEqualToIgnoringCase("first");
    BDDAssertions.then(saved.getFirstName()).isNotBlank();

    BDDAssertions.then(saved.getLastName()).isEqualToIgnoringCase("last");
    BDDAssertions.then(saved.getLastName()).isNotBlank();

    BDDAssertions.then(saved.getEmail()).isEqualToIgnoringCase("[email protected]");
    BDDAssertions.then(saved.getLastName()).isNotBlank();
}
 
开发者ID:applied-continuous-delivery-livelessons,项目名称:cdct,代码行数:18,代码来源:CustomerRepositoryTest.java

示例3: customerByIdShouldReturnACustomer

import org.assertj.core.api.BDDAssertions; //导入依赖的package包/类
@Test
public void customerByIdShouldReturnACustomer() {

    WireMock.stubFor(WireMock.get(WireMock.urlMatching("/customers/1"))
            .willReturn(
                    WireMock.aResponse()
                            .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE)
                            .withStatus(HttpStatus.OK.value())
                            .withBody(asJson(customerById))
            ));

    Customer customer = client.getCustomerById(1L);
    BDDAssertions.then(customer.getFirstName()).isEqualToIgnoringCase("first");
    BDDAssertions.then(customer.getLastName()).isEqualToIgnoringCase("last");
    BDDAssertions.then(customer.getEmail()).isEqualToIgnoringCase("email");
    BDDAssertions.then(customer.getId()).isEqualTo(1L);
}
 
开发者ID:applied-continuous-delivery-livelessons,项目名称:testing-101,代码行数:18,代码来源:CustomerClientWiremockTest.java

示例4: clientCanTalkToService

import org.assertj.core.api.BDDAssertions; //导入依赖的package包/类
@Test
public void clientCanTalkToService() {

    cf.applications()
            .pushManifest(
                    PushApplicationManifestRequest
                            .builder()
                            .manifest(ApplicationManifestUtils.read(this.manifest.toPath()).get(0))
                            .build())
            .block();

    Customer customerById = this.client.getCustomerById(1L);
    BDDAssertions.then(customerById.getId()).isEqualTo(1L);
    BDDAssertions.then(customerById.getFirstName()).isEqualTo("a");
    BDDAssertions.then(customerById.getLastName()).isEqualTo("a");
    BDDAssertions.then(customerById.getEmail()).isEqualTo("[email protected]");
}
 
开发者ID:applied-continuous-delivery-livelessons,项目名称:testing-101,代码行数:18,代码来源:CustomerItApplicationTests.java

示例5: should_create_a_valid_span_from_custom_headers

import org.assertj.core.api.BDDAssertions; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void should_create_a_valid_span_from_custom_headers() {
	final Span newSpan = this.tracer.createSpan("new_span");
	ResponseEntity<Map> responseEntity = null;
	try {
		RequestEntity<?> requestEntity = RequestEntity
				.get(URI.create("http://localhost:" + this.config.port + "/headers"))
				.build();
		responseEntity = this.restTemplate.exchange(requestEntity, Map.class);

		} finally {
		this.tracer.close(newSpan);
	}
	await().atMost(5, SECONDS).untilAsserted(() -> {
		then(this.accumulator.getSpans().stream().filter(
				span -> span.getSpanId() == newSpan.getSpanId()).findFirst().get())
				.hasTraceIdEqualTo(newSpan.getTraceId());
	});
	BDDAssertions.then(responseEntity.getBody())
			.containsEntry("correlationid", Span.idToHex(newSpan.getTraceId()))
			.containsKey("myspanid")
			.as("input request headers");
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:25,代码来源:TraceFilterCustomExtractorTests.java

示例6: should_close_span_upon_failure_callback

import org.assertj.core.api.BDDAssertions; //导入依赖的package包/类
@Test
public void should_close_span_upon_failure_callback()
		throws ExecutionException, InterruptedException {
	ListenableFuture<ResponseEntity<String>> future;
	try {
		future = this.asyncRestTemplate
				.getForEntity("http://localhost:" + port() + "/blowsup", String.class);
		future.get();
		BDDAssertions.fail("should throw an exception from the controller");
	} catch (Exception e) {

	}

	Awaitility.await().untilAsserted(() -> {
		then(new ArrayList<>(this.accumulator.getSpans()).stream()
				.filter(span -> span.logs().stream().filter(log -> Span.CLIENT_RECV.equals(log.getEvent()))
						.findFirst().isPresent()).findFirst().get()).matches(
				span -> span.getAccumulatedMicros() >= TimeUnit.MILLISECONDS.toMicros(100))
				.hasATagWithKey(Span.SPAN_ERROR_TAG_NAME);
		then(this.tracer.getCurrentSpan()).isNull();
		then(ExceptionUtils.getLastException()).isNull();
	});
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:24,代码来源:TraceWebAsyncClientAutoConfigurationTests.java

示例7: test

import org.assertj.core.api.BDDAssertions; //导入依赖的package包/类
public void test() {
    final SQSProjectSettings holder = new SQSProjectSettings();
    BDDAssertions.then(holder.getInfo("serverId")).isNull();

    holder.setInfo("serverId", XMLBasedSQSInfoHelper.createServerInfo("serverId"));
    BDDAssertions.then(holder.getInfo("serverId")).isNotNull();
    BDDAssertions.then(holder.getInfo("serverId2")).isNull();

    holder.setInfo("serverId2", XMLBasedSQSInfoHelper.createServerInfo("serverId2"));
    BDDAssertions.then(holder.getInfo("serverId")).isNotNull();
    BDDAssertions.then(holder.getInfo("serverId2")).isNotNull();

    holder.remove("serverId");
    holder.remove("serverId2");
    BDDAssertions.then(holder.getInfo("serverId")).isNull();
    BDDAssertions.then(holder.getInfo("serverId2")).isNull();
}
 
开发者ID:JetBrains,项目名称:TeamCity.SonarQubePlugin,代码行数:18,代码来源:SQSProjectSettingsTest.java

示例8: should_remove_from_both

import org.assertj.core.api.BDDAssertions; //导入依赖的package包/类
public void should_remove_from_both() throws IOException {
    final SQSManagerImpl sqsManager = mock(SQSManagerImpl.class);
    final SQSManagerProjectFeatures sqsManagerProjectFeatures = mock(SQSManagerProjectFeatures.class);
    final MigratingSQSManager migratingSQSManager = new MigratingSQSManager(sqsManager, sqsManagerProjectFeatures, mock(ConfigActionFactory.class));

    final BaseSQSInfo any = new BaseSQSInfo("any");

    when(sqsManagerProjectFeatures.removeServer(any(), any())).thenReturn(new SQSManager.SQSActionResult(any, null, ""));
    when(sqsManager.removeServer(any(), any())).thenReturn(new SQSManager.SQSActionResult(any, null, ""));

    final SQSManager.SQSActionResult result = migratingSQSManager.removeServer(myProject, "any");
    verify(sqsManagerProjectFeatures, times(1)).removeServer(myProject, "any");
    verify(sqsManager, times(1)).removeServer(myProject, "any");
    BDDAssertions.then(result.getBeforeAction()).isNotNull();
    BDDAssertions.then(result.isError()).isFalse();

    reset(sqsManagerProjectFeatures, sqsManager);
    when(sqsManagerProjectFeatures.removeServer(any(), any())).thenReturn(new SQSManager.SQSActionResult(null, null, "", true));
    when(sqsManager.removeServer(any(), any())).thenReturn(new SQSManager.SQSActionResult(null, null, "", true));

    final SQSManager.SQSActionResult result2 = migratingSQSManager.removeServer(myProject, "any");
    verify(sqsManagerProjectFeatures, times(1)).removeServer(myProject, "any");
    verify(sqsManager, times(1)).removeServer(myProject, "any");
    BDDAssertions.then(result2.getBeforeAction()).isNull();
    BDDAssertions.then(result2.isError()).isTrue();
}
 
开发者ID:JetBrains,项目名称:TeamCity.SonarQubePlugin,代码行数:27,代码来源:MigratingSQSManagerTest.java

示例9: should_first_fail_then_succeed_to_process_tax_factor_for_person

import org.assertj.core.api.BDDAssertions; //导入依赖的package包/类
@Test
public void should_first_fail_then_succeed_to_process_tax_factor_for_person() throws ConnectException {
    // given
    willThrow(new ConnectException()).willNothing().given(taxFactorService).updateMeanTaxFactor(any(Person.class), anyDouble());
 
 // when
 when(systemUnderTest).processTaxDataFor(new Person());

 // then
    then(caughtException()).hasCauseInstanceOf(ConnectException.class);

 // when
 boolean success = systemUnderTest.processTaxDataFor(new Person());

 // then
    BDDAssertions.then(success).isTrue();
}
 
开发者ID:marcingrzejszczak,项目名称:mockito-cookbook,代码行数:18,代码来源:PersonDataUpdatorTestNgTest.java

示例10: customerByIdShouldReturnACustomer

import org.assertj.core.api.BDDAssertions; //导入依赖的package包/类
@Test
public void customerByIdShouldReturnACustomer() {

    Customer customer = client.getCustomerById(1L);
    BDDAssertions.then(customer.getFirstName()).isEqualToIgnoringCase("first");
    BDDAssertions.then(customer.getLastName()).isEqualToIgnoringCase("last");
    BDDAssertions.then(customer.getEmail()).isEqualToIgnoringCase("email");
    BDDAssertions.then(customer.getId()).isEqualTo(1L);
}
 
开发者ID:applied-continuous-delivery-livelessons,项目名称:cdct,代码行数:10,代码来源:CustomerClientWiremockTest.java

示例11: customerByIdShouldReturnACustomer

import org.assertj.core.api.BDDAssertions; //导入依赖的package包/类
@Test
public void customerByIdShouldReturnACustomer() {

    this.mockRestServiceServer
            .expect(ExpectedCount.manyTimes(), requestTo("http://localhost:8080/customers/1"))
            .andExpect(method(HttpMethod.GET))
            .andRespond(withSuccess(this.customerById, MediaType.APPLICATION_JSON_UTF8));

    Customer customer = client.getCustomerById(1L);
    BDDAssertions.then(customer.getFirstName()).isEqualToIgnoringCase("first");
    BDDAssertions.then(customer.getLastName()).isEqualToIgnoringCase("last");
    BDDAssertions.then(customer.getEmail()).isEqualToIgnoringCase("email");
    BDDAssertions.then(customer.getId()).isEqualTo(1L);
    this.mockRestServiceServer.verify();
}
 
开发者ID:applied-continuous-delivery-livelessons,项目名称:cdct,代码行数:16,代码来源:CustomerClientRestServiceServerTest.java

示例12: newInstanceWithValidValuesShouldReturnARecord

import org.assertj.core.api.BDDAssertions; //导入依赖的package包/类
@Test
public void newInstanceWithValidValuesShouldReturnARecord() {
    Customer customer = new Customer(1L, "first", "last", "[email protected]");
    BDDAssertions.then(customer.getFirstName()).isEqualToIgnoringCase("first");
    BDDAssertions.then(customer.getLastName()).isEqualToIgnoringCase("last");
    BDDAssertions.then(customer.getEmail()).isEqualToIgnoringCase("[email protected]");
    BDDAssertions.then(customer.getId()).isNotNull();
}
 
开发者ID:applied-continuous-delivery-livelessons,项目名称:cdct,代码行数:9,代码来源:CustomerTest.java

示例13: should_return_charge_collection

import org.assertj.core.api.BDDAssertions; //导入依赖的package包/类
@Test
public void should_return_charge_collection() {
	Charges charges = manager.listAllCharges("foo");

	BDDAssertions.then(charges.getCharges())
			.hasSize(25);
}
 
开发者ID:marcingrzejszczak,项目名称:the-legacy-app,代码行数:8,代码来源:CustomerWithStubRunnerProxyTests.java

示例14: should_return_charge_collection

import org.assertj.core.api.BDDAssertions; //导入依赖的package包/类
@Test
public void should_return_charge_collection() {
	String object = new RestTemplate()
			.getForObject("http://localhost:7654/", String.class);

	BDDAssertions.then(object).contains("dsyer");
}
 
开发者ID:marcingrzejszczak,项目名称:the-legacy-app,代码行数:8,代码来源:OnlineModeTests.java

示例15: should_return_charge_collection

import org.assertj.core.api.BDDAssertions; //导入依赖的package包/类
@Test
public void should_return_charge_collection() {
	Charges charges = manager.listAllCharges("foo");

	BDDAssertions.then(charges.getCharges())
			.extracting("customer")
			.containsExactly("a", "b", "c");
}
 
开发者ID:marcingrzejszczak,项目名称:the-legacy-app,代码行数:9,代码来源:CustomerRentalHistoryManagerImplTests.java


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