當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。