org.fest.assertions.ListAssert.as()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(13.7k)|赞(0)|评价(0)|浏览(119)

本文整理了Java中org.fest.assertions.ListAssert.as()方法的一些代码示例,展示了ListAssert.as()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ListAssert.as()方法的具体详情如下:
包路径:org.fest.assertions.ListAssert
类名称:ListAssert
方法名:as

ListAssert.as介绍

暂无

代码示例

代码示例来源:origin: debezium/debezium

final List<?> actualValueList = (List<?>)actualValue;
final List<?> valueList = (List<?>)value;
Assertions.assertThat(actualValueList).as("List size don't match for " + fieldName).hasSize(valueList.size());
if (!valueList.isEmpty() && valueList.iterator().next() instanceof Struct) {
  for (int i = 0; i < valueList.size(); i++) {

代码示例来源:origin: gosu-lang/old-gosu-repo

public void assertManifestContainsSourcesEntry(IDirectory dir, String expectedSources) {
 HashSet<String> found = new HashSet<String>();
 DynamicArray<? extends IFile> files = IDirectoryUtil.allContainedFilesExcludingIgnored(dir);
 for (IFile file : files) {
  String extension = file.getExtension();
  if (extension.equals("gs") || extension.equals("gsx") || extension.equals("xsd")) {
   found.add(extension);
  }
 }
 List<String> foundExtensions = new ArrayList<String>(found);
 Collections.sort(foundExtensions);
 if (expectedSources != null) {
  List<String> expectedSourceExtensions = Arrays.asList(expectedSources.split(","));
  Assertions.assertThat(foundExtensions)
      .as("the set of extensions in the manifest (Contains-Sources) don't match the set found in the jar")
      .isEqualTo(expectedSourceExtensions);
  assertEquals(expectedSources, _mf.getMainAttributes().getValue("Contains-Sources"));
 }
 else {
  Assertions.assertThat(foundExtensions).isEmpty();
  assertNull(_mf.getMainAttributes().getValue("Contains-Sources"));
 }
}

代码示例来源:origin: com.facebook.swift/swift-service

public static void verifyPumaResults(List<ReadResultQueryInfoTimeString> results)
  {
    assertThat(results)
        .as("results")
        .hasSize(2)
        .containsSequence(
            new ReadResultQueryInfoTimeString("now", ImmutableMap.of("apple", "apple", "banana", "banana")),
            new ReadResultQueryInfoTimeString("snack", ImmutableMap.of("cheetos", "cheetos", "doritos", "doritos"))
        );
  }
}

代码示例来源:origin: com.facebook.swift/swift-codec

@Test
public void testMultipleTypes()
    throws Exception
{
  ThriftUnionMetadataBuilder builder = new ThriftUnionMetadataBuilder(new ThriftCatalog(), MultipleTypes.class);
  MetadataErrors metadataErrors = builder.getMetadataErrors();
  assertThat(metadataErrors.getErrors())
      .as("metadata errors")
      .hasSize(1);
  assertThat(metadataErrors.getWarnings())
      .as("metadata warnings")
      .isEmpty();
  assertThat(metadataErrors.getErrors().get(0).getMessage())
      .as("error message")
      .containsIgnoringCase("multiple types");
}

代码示例来源:origin: com.facebook.swift/swift-service

@Test(dataProvider="getTestCasesWithLegacyFieldIds")
public void testLegacyFieldIds(Method[] mBox)
{
  Method m = mBox[0];
  ThriftMethodMetadata metadata = new ThriftMethodMetadata("DummyService", m, new ThriftCatalog());
  List<ThriftFieldMetadata> parameters = metadata.getParameters();
  assertThat(parameters)
      .as("parameters")
      .hasSize(1);
  assertThat(parameters.get(0).getId())
      .as("the parameter's ID")
      .isNegative();
}

代码示例来源:origin: com.facebook.swift/swift-service

@Test(dataProvider="getTestCasesWithNonLegacyFieldIds")
public void testNonLegacyFieldIds(Method[] mBox)
{
  Method m = mBox[0];
  ThriftMethodMetadata metadata = new ThriftMethodMetadata("DummyService", m, new ThriftCatalog());
  List<ThriftFieldMetadata> parameters = metadata.getParameters();
  assertThat(parameters)
      .as("parameters")
      .hasSize(1);
  assertThat(parameters.get(0).getId())
      .as("the parameter's ID")
      .isGreaterThanOrEqualTo((short) 0);
}

代码示例来源:origin: com.facebook.swift/swift-codec

@Test
public void testMulitpleRequiredness()
{
  ThriftStructMetadataBuilder builder = new ThriftStructMetadataBuilder(new ThriftCatalog(), MultipleRequiredness.class);
  MetadataErrors metadataErrors = builder.getMetadataErrors();
  assertThat(metadataErrors.getErrors())
      .as("metadata errors")
      .hasSize(1);
  assertThat(metadataErrors.getWarnings())
      .as("metadata warnings")
      .isEmpty();
  assertThat(metadataErrors.getErrors().get(0).getMessage())
      .as("error message")
      .containsIgnoringCase("multiple requiredness");
}

代码示例来源:origin: com.facebook.swift/swift-codec

@Test
public void testUnsupportedType()
    throws Exception
{
  ThriftStructMetadataBuilder builder = new ThriftStructMetadataBuilder(new ThriftCatalog(), UnsupportedJavaType.class);
  MetadataErrors metadataErrors = builder.getMetadataErrors();
  assertThat(metadataErrors.getErrors())
      .as("metadata errors")
      .hasSize(1);
  assertThat(metadataErrors.getWarnings())
      .as("metadata warnings")
      .isEmpty();
  assertThat(metadataErrors.getErrors().get(0).getMessage())
      .as("error message")
      .containsIgnoringCase("not a supported Java type");
}

代码示例来源:origin: com.facebook.swift/swift-codec

@Test
public void testMultipleIds()
    throws Exception
{
  ThriftStructMetadataBuilder builder = new ThriftStructMetadataBuilder(new ThriftCatalog(), MultipleIds.class);
  MetadataErrors metadataErrors = builder.getMetadataErrors();
  assertThat(metadataErrors.getErrors())
      .as("metadata errors")
      .hasSize(1);
  assertThat(metadataErrors.getWarnings())
      .as("metadata warnings")
      .isEmpty();
  assertThat(metadataErrors.getErrors().get(0).getMessage())
      .as("error message")
      .containsIgnoringCase("multiple ids");
}

代码示例来源:origin: com.facebook.swift/swift-codec

@Test
public void testNoId()
    throws Exception
{
  ThriftStructMetadataBuilder builder = new ThriftStructMetadataBuilder(new ThriftCatalog(), NoId.class);
  MetadataErrors metadataErrors = builder.getMetadataErrors();
  assertThat(metadataErrors.getErrors())
      .as("metadata errors")
      .hasSize(1);
  assertThat(metadataErrors.getWarnings())
      .as("metadata warnings")
      .isEmpty();
  assertThat(metadataErrors.getErrors().get(0).getMessage())
      .as("error message")
      .containsIgnoringCase("not have an id");
}

代码示例来源:origin: com.facebook.swift/swift-codec

@Test
public void testMultipleTypes()
    throws Exception
{
  ThriftStructMetadataBuilder builder = new ThriftStructMetadataBuilder(new ThriftCatalog(), MultipleTypes.class);
  MetadataErrors metadataErrors = builder.getMetadataErrors();
  assertThat(metadataErrors.getErrors())
      .as("metadata errors")
      .hasSize(1);
  assertThat(metadataErrors.getWarnings())
      .as("metadata warnings")
      .isEmpty();
  assertThat(metadataErrors.getErrors().get(0).getMessage())
      .as("error message")
      .containsIgnoringCase("multiple types");
}

代码示例来源:origin: com.facebook.swift/swift-codec

@Test
public void testMultipleNames()
    throws Exception
{
  ThriftUnionMetadataBuilder builder = new ThriftUnionMetadataBuilder(new ThriftCatalog(), MultipleNames.class);
  MetadataErrors metadataErrors = builder.getMetadataErrors();
  assertThat(metadataErrors.getErrors())
      .as("metadata errors")
      .isEmpty();
  assertThat(metadataErrors.getWarnings())
      .as("metadata warnings")
      .hasSize(1);
  assertThat(metadataErrors.getWarnings().get(0).getMessage())
      .as("error message")
      .containsIgnoringCase("multiple names");
}

代码示例来源:origin: com.facebook.swift/swift-codec

@Test
public void testMultipleNames()
    throws Exception
{
  ThriftStructMetadataBuilder builder = new ThriftStructMetadataBuilder(new ThriftCatalog(), MultipleNames.class);
  MetadataErrors metadataErrors = builder.getMetadataErrors();
  assertThat(metadataErrors.getErrors())
      .as("metadata errors")
      .isEmpty();
  assertThat(metadataErrors.getWarnings())
      .as("metadata warnings")
      .hasSize(1);
  assertThat(metadataErrors.getWarnings().get(0).getMessage())
      .as("error message")
      .containsIgnoringCase("multiple names");
}

代码示例来源:origin: com.facebook.swift/swift-codec

@Test
public void testNoId()
    throws Exception
{
  ThriftUnionMetadataBuilder builder = new ThriftUnionMetadataBuilder(new ThriftCatalog(), NoId.class);
  MetadataErrors metadataErrors = builder.getMetadataErrors();
  assertThat(metadataErrors.getErrors())
      .as("metadata errors")
      .hasSize(1);
  assertThat(metadataErrors.getWarnings())
      .as("metadata warnings")
      .isEmpty();
  assertThat(metadataErrors.getErrors().get(0).getMessage())
      .as("error message")
      .containsIgnoringCase("not have an id");
}

代码示例来源:origin: com.facebook.swift/swift-codec

@Test
public void testMultipleIds()
    throws Exception
{
  ThriftUnionMetadataBuilder builder = new ThriftUnionMetadataBuilder(new ThriftCatalog(), MultipleIds.class);
  MetadataErrors metadataErrors = builder.getMetadataErrors();
  assertThat(metadataErrors.getErrors())
      .as("metadata errors")
      .hasSize(1);
  assertThat(metadataErrors.getWarnings())
      .as("metadata warnings")
      .isEmpty();
  assertThat(metadataErrors.getErrors().get(0).getMessage())
      .as("error message")
      .containsIgnoringCase("multiple ids");
}

代码示例来源:origin: com.facebook.swift/swift-codec

@Test
public void testUnsupportedType()
    throws Exception
{
  ThriftUnionMetadataBuilder builder = new ThriftUnionMetadataBuilder(new ThriftCatalog(), UnsupportedJavaType.class);
  MetadataErrors metadataErrors = builder.getMetadataErrors();
  assertThat(metadataErrors.getErrors())
      .as("metadata errors")
      .hasSize(1);
  assertThat(metadataErrors.getWarnings())
      .as("metadata warnings")
      .isEmpty();
  assertThat(metadataErrors.getErrors().get(0).getMessage())
      .as("error message")
      .containsIgnoringCase("not a supported Java type");
}

代码示例来源:origin: hibernate/hibernate-ogm

@Test
public void testOrderedList() throws Exception {
  father.getOrderedChildren().add( luke );
  father.getOrderedChildren().add( null );
  father.getOrderedChildren().add( leia );
  inTransaction( session -> {
    session.persist( luke );
    session.persist( leia );
    session.persist( father );
  } );
  inTransaction( session -> {
    father = (Father) session.get( Father.class, father.getId() );
    assertThat( father.getOrderedChildren() )
        .as( "List should have 3 elements" )
        .hasSize( 3 );
    assertThat( father.getOrderedChildren().get( 0 ).getName() )
        .as( "Luke should be first" )
        .isEqualTo( luke.getName() );
    assertThat( father.getOrderedChildren().get( 1 ) )
        .as( "Second born should be null" )
        .isNull();
    assertThat( father.getOrderedChildren().get( 2 ).getName() )
        .as( "Leia should be third" )
        .isEqualTo( leia.getName() );
  } );
}

代码示例来源:origin: org.codehaus.sonar-plugins.css/css-checks-testkit

private static void verifyIssue(TestIssue expected, Issue actual, File file) {
 if (line(actual) > expected.line()) {
  fail("Missing issue at line " + expected.line() + " in file " + file.getAbsolutePath());
 }
 if (line(actual) < expected.line()) {
  fail("Unexpected issue at line " + line(actual) + ": \"" + message(actual) + "\"" + " in file " + file.getAbsolutePath());
 }
 if (expected.message() != null) {
  assertThat(message(actual)).as("Bad message at line " + expected.line()).isEqualTo(expected.message());
 }
 if (expected.effortToFix() != null) {
  assertThat(actual.cost()).as("Bad effortToFix at line " + expected.line()).isEqualTo(expected.effortToFix());
 }
 if (expected.startColumn() != null) {
  assertThat(((PreciseIssue) actual).primaryLocation().startLineOffset() + 1).as("Bad start column at line " + expected.line()).isEqualTo(expected.startColumn());
 }
 if (expected.endColumn() != null) {
  assertThat(((PreciseIssue) actual).primaryLocation().endLineOffset() + 1).as("Bad end column at line " + expected.line()).isEqualTo(expected.endColumn());
 }
 if (expected.endLine() != null) {
  assertThat(((PreciseIssue) actual).primaryLocation().endLine()).as("Bad end line at line " + expected.line()).isEqualTo(expected.endLine());
 }
 if (expected.secondaryLines() != null) {
  assertThat(secondary(actual)).as("Bad secondary locations at line " + expected.line()).isEqualTo(expected.secondaryLines());
 }
}

代码示例来源:origin: hibernate/hibernate-ogm

@Test
@TestForIssue(jiraKey = "OGM-1537")
public void testDuplicatesForElementsCollectionWithoutOrderColumn() {
  Meeting meeting = new Meeting();
  meeting.setName( NAME );
  meeting.addAddress( ADDRESS_0 );
  meeting.addAddress( ADDRESS_0 );
  meeting.addAddress( ADDRESS_1 );
  meeting.addAddress( ADDRESS_0 );
  meeting.addAddress( ADDRESS_2 );
  inTransaction( session -> {
    persistAll( session, meeting );
  } );
  inTransaction( session -> {
    Meeting load = session.load( Meeting.class, NAME );
    assertThat( load.getAddresses() ).hasSize( 3 );
    assertThat( load.getAddresses() )
      .as( "Hibernate OGM does not support duplicates for a collection of embeddebles (issue OGM-1537)."
          + " If you've solved this issue, congratulations!"
          + " Please, update the jira and this test accordingly, and thanks a lot" )
      .containsOnly( ADDRESS_0, ADDRESS_1, ADDRESS_2 );
    // it should be:
    // assertThat( load.getAddresses() ).containsExactly( ADDRESS_0, ADDRESS_0, ADDRESS_1, ADDRESS_0, ADDRESS_2 );
  } );
}

代码示例来源:origin: hibernate/hibernate-ogm

@Test
@TestForIssue(jiraKey = "OGM-1537")
public void testDuplicatesForOneToManyAssociationWithoutOrderColumn() {
  Programmer participant0 = new Programmer( PARTICIPANT_0 );
  Programmer participant1 = new Programmer( PARTICIPANT_1 );
  Programmer participant2 = new Programmer( PARTICIPANT_2 );
  Meeting meeting = new Meeting();
  meeting.setName( NAME );
  meeting.addParticipant( participant0 );
  meeting.addParticipant( participant1 );
  meeting.addParticipant( participant1 );
  meeting.addParticipant( participant2 );
  meeting.addParticipant( participant1 );
  inTransaction( session -> {
    persistAll( session, meeting, participant0, participant1, participant2 );
  } );
  inTransaction( session -> {
    Meeting load = session.load( Meeting.class, NAME );
    assertThat( load.getParticipants() ).hasSize( 3 );
    assertThat( load.getParticipants() )
      .as( "Hibernate OGM does not support duplicates for associations (issue OGM-1537)."
          + " If you've solved this issue, congratulations!"
          + " Please, update the jira and this test accordingly, and thanks a lot" )
      .containsOnly( participant0, participant1, participant2 );
    // It should be:
    // assertThat( load.getParticipants() ).containsExactly( participant0, participant1, participant1, participant2, participant1 );
  } );
}

相关文章