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


Java Assertions类代码示例

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


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

示例1: testConstructorFromByteArray

import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Test
public void testConstructorFromByteArray() {
    final RowKey rowKey = new RowKey(buildRowKeyArray());
    assertEquals(STAT_TYPE_ID, rowKey.getTypeId());
    Assertions.assertThat(ROLL_UP_BIT_MASK).isEqualTo(rowKey.getRollUpBitMask());
    Assertions.assertThat(PARTIAL_TIMESTAMP).isEqualTo(rowKey.getPartialTimestamp());

    final List<RowKeyTagValue> tagValuePairs = rowKey.getTagValuePairs();

    assertEquals(3, tagValuePairs.size());

    assertEquals(TAG_2, tagValuePairs.get(0).getTag());
    assertEquals(VALUE_2, tagValuePairs.get(0).getValue());
    assertEquals(TAG_1, tagValuePairs.get(1).getTag());
    assertEquals(VALUE_1, tagValuePairs.get(1).getValue());
    assertEquals(TAG_3, tagValuePairs.get(2).getTag());
    assertEquals(VALUE_3, tagValuePairs.get(2).getValue());
}
 
开发者ID:gchq,项目名称:stroom-stats,代码行数:19,代码来源:TestRowKey.java

示例2: call

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

    // given
    HelloWorldWork work1 = new HelloWorldWork("work1", WorkStatus.COMPLETED);
    HelloWorldWork work2 = new HelloWorldWork("work2", WorkStatus.FAILED);
    ParallelFlowExecutor parallelFlowExecutor = new ParallelFlowExecutor();

    // when
    List<WorkReport> workReports = parallelFlowExecutor.executeInParallel(Arrays.asList(work1, work2));

    // then
    Assertions.assertThat(workReports).hasSize(2);
    Assertions.assertThat(work1.isExecuted()).isTrue();
    Assertions.assertThat(work2.isExecuted()).isTrue();
}
 
开发者ID:j-easy,项目名称:easy-flows,代码行数:17,代码来源:ParallelFlowExecutorTest.java

示例3: deleteAsyncCollection

import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Test
public void deleteAsyncCollection() throws Exception {
    TestLongEntity[] entities = fixture.get(3);
    ofy().save().entities(entities).now();

    List<TestLongEntity> listBeforeDelete = ofy().load().type(TestLongEntity.class).list();
    Assertions.assertThat(listBeforeDelete).hasSize(3);

    repository.deleteAsync(
            Arrays.asList(entities[0], entities[1])
    ).run();

    List<TestLongEntity> listAfterDelete = ofy().load().type(TestLongEntity.class).list();
    Assertions.assertThat(listAfterDelete).hasSize(1);
    Assertions.assertThat(listAfterDelete).containsExactly(entities[2]);
}
 
开发者ID:n15g,项目名称:spring-boot-gae,代码行数:17,代码来源:LongAsyncDeleteRepositoryTest.java

示例4: validateIntegration

import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Then("^validate record is present in SF \"([^\"]*)\"")
public void validateIntegration(String record) throws TwitterException {
	Assertions.assertThat(getSalesforceContact(salesforce, accountsDirectory.getAccount(RestConstants.getInstance().getSYNDESIS_TALKY_ACCOUNT())
			.get().getProperty("screenName")).isPresent()).isEqualTo(false);

	log.info("Waiting until a contact appears in salesforce...");
	final long start = System.currentTimeMillis();
	final boolean contactCreated = TestUtils.waitForEvent(contact -> contact.isPresent(),
			() -> getSalesforceContact(salesforce, accountsDirectory.getAccount(RestConstants.getInstance().getSYNDESIS_TALKY_ACCOUNT()).get().getProperty("screenName")),
			TimeUnit.MINUTES,
			2,
			TimeUnit.SECONDS,
			5);
	Assertions.assertThat(contactCreated).as("Contact has appeard in salesforce").isEqualTo(true);
	log.info("Contact appeared in salesforce. It took {}s to create contact.", TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - start));

	final Contact createdContact = getSalesforceContact(salesforce, accountsDirectory.getAccount(RestConstants.getInstance().getSYNDESIS_TALKY_ACCOUNT()).get().getProperty("screenName")).get();
	Assertions.assertThat(createdContact.getDescription()).startsWith(record);
	Assertions.assertThat(createdContact.getFirstName()).isNotEmpty();
	Assertions.assertThat(createdContact.getLastname()).isNotEmpty();
	log.info("Twitter to salesforce integration test finished.");
}
 
开发者ID:syndesisio,项目名称:syndesis-qe,代码行数:23,代码来源:TwSfValidationSteps.java

示例5: visit_shouldVisitAllItems

import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Test
public void visit_shouldVisitAllItems() throws Exception {
  //given
  List<Object> list = new ArrayList<>();
  OutputContainer.CellVisitor visitor = new OutputContainer.CellVisitor() {
    @Override
    public void visit(Object item) {
      list.add(item);
    }
  };
  container.addItem(Integer.MIN_VALUE, 0);
  container.addItem(Boolean.TRUE, 1);
  //when
  container.visit(visitor);
  //then
  Assertions.assertThat(list).isNotEmpty();
  Assertions.assertThat(list.size()).isEqualTo(2);
  Assertions.assertThat(list.get(1)).isEqualTo(true);
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:20,代码来源:OutputContainerTest.java

示例6: rxSingleIntFallback

import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Test
public void rxSingleIntFallback() {
  server.enqueue(new MockResponse().setResponseCode(500));

  TestInterface api = target();

  Single<Integer> single = api.intSingle();

  assertThat(single).isNotNull();
  assertThat(server.getRequestCount()).isEqualTo(0);

  TestSubscriber<Integer> testSubscriber = new TestSubscriber<Integer>();
  single.subscribe(testSubscriber);
  testSubscriber.awaitTerminalEvent();
  Assertions.assertThat(testSubscriber.getOnNextEvents().get(0)).isEqualTo(new Integer(0));
}
 
开发者ID:wenwu315,项目名称:XXXX,代码行数:17,代码来源:HystrixBuilderTest.java

示例7: discoveryClientWithWrongUrlShouldUseServiceInstanceInfo

import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Test
public void discoveryClientWithWrongUrlShouldUseServiceInstanceInfo() {
    String serviceId = "serviceId";
    URI uri = URI.create("http://service-instance-uri");
    EurekaServiceInstance serviceInstanceMock = Mockito.mock(EurekaServiceInstance.class);
    Mockito.when(serviceInstanceMock.getUri()).thenReturn(uri);
    Mockito.when(serviceInstanceMock.getServiceId()).thenReturn(serviceId);
    Mockito.when(discoveryClient.getServices()).thenReturn(Lists.newArrayList("serviceId"));
    Mockito.when(discoveryClient.getInstances("serviceId")).thenReturn(Lists.newArrayList(serviceInstanceMock));
    Mockito.when(serviceInstanceMock.getMetadata())
            .thenReturn(Maps.newHashMap(CereebroMetadata.KEY_SNITCH_URI, ""));
    DiscoveryClientSnitchRegistry registry = new DiscoveryClientSnitchRegistry(discoveryClient, objectMapper);
    Assertions.assertThat(registry.getAll()).hasSize(1);
    Snitch snitch = registry.getAll().get(0);
    Assertions.assertThat(snitch).isInstanceOf(ServiceInstanceSnitch.class);
    Assertions.assertThat(snitch.getUri()).isEqualTo(uri);
    Component component = Component.of(serviceId, ComponentType.HTTP_APPLICATION);
    SystemFragment expected = SystemFragment.of(ComponentRelationships.of(component, new HashSet<>()));
    Assertions.assertThat(snitch.snitch()).isEqualTo(expected);
}
 
开发者ID:cereebro,项目名称:cereebro,代码行数:21,代码来源:EurekaSnitchRegistryTest.java

示例8: assertLogsContainsOrNot

import org.assertj.core.api.Assertions; //导入依赖的package包/类
public static void assertLogsContainsOrNot(Collection<Pod> pods, String[] shouldFinds, String[] shouldNotFinds) throws IOException {
	Pattern patterns[] = new Pattern[shouldFinds.length + shouldNotFinds.length];

	for (int i = 0; i < shouldFinds.length; ++i) {
		patterns[i] = Pattern.compile(shouldFinds[i]);
	}

	for (int i = 0; i < shouldNotFinds.length; ++i) {
		patterns[shouldFinds.length + i] = Pattern.compile(shouldNotFinds[i]);
	}

	boolean found[] = findPatternsInLogs(pods, patterns);

	for (int i = 0; i < patterns.length; ++i) {
		if (i < shouldFinds.length) {
			Assertions.assertThat(found[i]).as("Didn't find pattern '" + patterns[i].toString() + "' in pod " + formatPodLists(pods) + "logs").isEqualTo(true);
		} else {
			Assertions.assertThat(found[i]).as("Found pattern '" + patterns[i].toString() + "' in pod " + formatPodLists(pods) + "logs").isEqualTo(false);
		}
	}
}
 
开发者ID:syndesisio,项目名称:syndesis-qe,代码行数:22,代码来源:LogCheckerUtils.java

示例9: should_not_return_merged_test_selections_if_test_selection_has_different_class

import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Test
public void should_not_return_merged_test_selections_if_test_selection_has_different_class() {
    // given
    final TestSelection testSelectionNew = new TestSelection(TestExecutionPlannerLoaderTest.class.getName(), "new");
    final TestSelection testSelectionChanged =
        new TestSelection(TestSelectorTest.class.getName(), "changed");

    final Set<Class<?>> classes =
        new LinkedHashSet<>(asList(TestExecutionPlannerLoaderTest.class, TestSelectorTest.class));
    TestExecutionPlannerLoader testExecutionPlannerLoader = prepareLoader(classes);

    final DummyTestSelector testSelector =
        new DummyTestSelector(ConfigurationLoader.load(tmpFolder.getRoot()), testExecutionPlannerLoader,
            new File("."));

    // when
    final Collection<TestSelection> testSelections =
        testSelector.filterMergeAndOrderTestSelection(asList(testSelectionNew, testSelectionChanged),
            asList("new", "changed"));

    // then
    Assertions.assertThat(testSelections)
        .hasSize(2)
        .flatExtracting("types").containsExactly("new", "changed");
}
 
开发者ID:arquillian,项目名称:smart-testing,代码行数:26,代码来源:TestSelectorTest.java

示例10: handleMessage_secondSentMessageHasSessionId

import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Test
public void handleMessage_secondSentMessageHasSessionId() throws Exception {
  //given
  String expectedSessionId = message.getHeader().getSession();
  //when
  commMsgHandler.handle(message);
  //then
  Assertions.assertThat(kernel.getPublishedMessages()).isNotEmpty();
  Message publishMessage = kernel.getPublishedMessages().get(1);
  Assertions.assertThat(publishMessage.getHeader().getSession()).isEqualTo(expectedSessionId);
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:12,代码来源:CommMsgHandlerTest.java

示例11: create

import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Test
public void create() {
    Component a = Component.of("a", "a");
    Component b = Component.of("b", "b");
    Component c = Component.of("c", "c");
    ComponentRelationships aRels = ComponentRelationships.builder().component(a).addDependency(Dependency.on(b))
            .build();
    ComponentRelationships bRels = ComponentRelationships.builder().component(b).addDependency(Dependency.on(c))
            .build();
    ComponentRelationships cRels = ComponentRelationships.builder().component(c).build();

    LinkedHashSet<ComponentRelationships> set = new LinkedHashSet<>();
    set.add(aRels);
    set.add(bRels);
    set.add(cRels);
    System system = System.of("sys", set);

    DependencyWheel result = DependencyWheel.of(system);

    // @formatter:off
    DependencyWheel expected = DependencyWheel.builder()
            .name("a")
            .matrixLine(Arrays.asList(0, 1, 0))
            .name("b")
            .matrixLine(Arrays.asList(0, 0, 1))
            .name("c")
            .matrixLine(Arrays.asList(0, 0, 0))
            .build();
    // @formatter:on

    Assertions.assertThat(result).isEqualTo(expected);
}
 
开发者ID:cereebro,项目名称:cereebro,代码行数:33,代码来源:DependencyWheelTest.java

示例12: setBoundsWithTwoDoubleParams_hasBoundsValuesAndHasAutoRangeIsFalse

import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Test
public void setBoundsWithTwoDoubleParams_hasBoundsValuesAndHasAutoRangeIsFalse() {
  //when
  YAxis yAxis = new YAxis();
  yAxis.setBound(1, 2);
  //then
  Assertions.assertThat(yAxis.getAutoRange()).isEqualTo(false);
  Assertions.assertThat(yAxis.getLowerBound()).isEqualTo(1);
  Assertions.assertThat(yAxis.getUpperBound()).isEqualTo(2);
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:11,代码来源:YAxisTest.java

示例13: testSchemeAssets

import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Test
public void testSchemeAssets() throws Exception {
	String uri = "assets://folder/1.png";
	Scheme result = Scheme.ofUri(uri);
	Scheme expected = Scheme.ASSETS;
	Assertions.assertThat(result).isEqualTo(expected);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:BaseImageDownloaderTest.java

示例14: serializeStickyOfTreeMap_resultJsonHasSticky

import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Test
public void serializeStickyOfTreeMap_resultJsonHasSticky() throws IOException {
  //when
  treeMap.setSticky(true);
  treeMapSerializer.serialize(treeMap, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("sticky")).isTrue();
  Assertions.assertThat(actualObj.get("sticky").asBoolean()).isTrue();
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:12,代码来源:TreeMapSerializerTest.java

示例15: createPointsByEmptyConstructor_hasSizeAndShapeIsNotNull

import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Test
public void createPointsByEmptyConstructor_hasSizeAndShapeIsNotNull() {
  //when
  Points points = new Points();
  //then
  Assertions.assertThat(points.getSize()).isNotNull();
  Assertions.assertThat(points.getShape()).isNotNull();
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:9,代码来源:PointsTest.java


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