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


Java Truth类代码示例

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


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

示例1: encode

import com.google.common.truth.Truth; //导入依赖的package包/类
@Test
public void encode() {
    // Given
    PlayStatePacket expected = createDummyPlayStatePacket();

    ByteBuf buf = ByteBufAllocator.DEFAULT.buffer();
    buf.markReaderIndex();

    // When
    subject.encode(expected, buf);

    // Then
    PlayStatePacket actual = subject.decode(buf);
    assertThat(actual).isEqualTo(expected);
    Truth.assertThat(actual.getPlayState()).isEqualTo(expected.getPlayState());
}
 
开发者ID:JungleTree,项目名称:JungleTree,代码行数:17,代码来源:PlayStateCodecTest.java

示例2: testNRelatedToOneAP_creates_GeneratedFiles_WhenTwoFileToProcess

import com.google.common.truth.Truth; //导入依赖的package包/类
@Test
public void testNRelatedToOneAP_creates_GeneratedFiles_WhenTwoFileToProcess() {
  //GIVEN
  JavaFileObject source0 = forSourceString("test.Test0", "" //
      + "package test;\n" //
      + "import org.gradle.incap.Annotation1;\n" //
      + "@Annotation1\n" //
      + "public class Test0 {\n" //
      + "}\n" //
      + "@Annotation1\n" //
      + "class Test1 extends Test0{\n" //
      + "}");

  JavaFileObject expected10 = forSourceString("NRelatedToOneAP_Test1_Test0Gen0", "" //
      + "\n" //
      + "public class NRelatedToOneAP_Test1_Test0Gen0 {\n" //
      + "}");

  //WHEN
  //THEN
  Truth.assertAbout(JavaSourceSubjectFactory.javaSource()).that(source0) //
      .withCompilerOptions("-Xlint:-processing","-Aincap.mapping.folder=.", "-Aincap.incremental=true") //
      .processedWith(new NRelatedToOneAP()) //
      .compilesWithoutError().and().generatesSources(expected10);
}
 
开发者ID:gradle,项目名称:incap,代码行数:26,代码来源:NRelatedToOneAPTest.java

示例3: testNUnrelatedANDToOneAP_creates_GeneratedFiles_WhenSingleFileToProcess

import com.google.common.truth.Truth; //导入依赖的package包/类
@Test
public void testNUnrelatedANDToOneAP_creates_GeneratedFiles_WhenSingleFileToProcess() {
  //GIVEN
  JavaFileObject source = forSourceString("test.Test", "" //
      + "package test;\n" //
      + "import org.gradle.incap.Annotation1;\n" //
      + "@Annotation1\n" //
      + "public class Test {\n" //
      + "}");

  //WHEN
  //THEN
  Truth.assertAbout(JavaSourceSubjectFactory.javaSource()).that(source) //
      .withCompilerOptions("-Xlint:-processing","-Aincap.mapping.folder=.") //
      .processedWith(new NUnrelatedANDToOneAP()) //
      .compilesWithoutError();
  //we cannot assert that no file gets generated...
}
 
开发者ID:gradle,项目名称:incap,代码行数:19,代码来源:NUnrelatedANDToOneAPTest.java

示例4: testNUnrelatedANDToOneAP_creates_GeneratedFiles_WhenTwoFileToProcess

import com.google.common.truth.Truth; //导入依赖的package包/类
@Test
public void testNUnrelatedANDToOneAP_creates_GeneratedFiles_WhenTwoFileToProcess() {
  //GIVEN
  JavaFileObject source0 = forSourceString("test.Test0", "" //
      + "package test;\n" //
      + "import org.gradle.incap.Annotation1;\n" //
      + "@Annotation1\n" //
      + "public class Test0 {\n" //
      + "}\n" //
      + "@Annotation1\n" //
      + "class Test1 {\n" //
      + "}");
  JavaFileObject expected = forSourceString("NUnrelatedANDToOneAP_AND_Gen0", "" //
      + "\n" //
      + "public class NUnrelatedANDToOneAP_AND_Gen0 {\n" //
      + "}");

  //WHEN
  //THEN
  Truth.assertAbout(JavaSourceSubjectFactory.javaSource()).that(source0) //
      .withCompilerOptions("-Xlint:-processing","-Aincap.mapping.folder=.", "-Aincap.incremental=true") //
      .processedWith(new NUnrelatedANDToOneAP()) //
      .compilesWithoutError().and().generatesSources(expected);
}
 
开发者ID:gradle,项目名称:incap,代码行数:25,代码来源:NUnrelatedANDToOneAPTest.java

示例5: testOneToNAP_creates_GeneratedFiles_WhenSingleFileToProcess

import com.google.common.truth.Truth; //导入依赖的package包/类
@Test
public void testOneToNAP_creates_GeneratedFiles_WhenSingleFileToProcess() {
  //GIVEN
  JavaFileObject source = forSourceString("test.Test", "" //
      + "package test;\n" //
      + "import org.gradle.incap.Annotation1;\n" //
      + "@Annotation1\n" //
      + "public class Test {\n" //
      + "}");
  JavaFileObject expected0 = forSourceString("OneToNAP_TestGen0", "" //
      + "\n" //
      + "public class OneToNAP_TestGen0 {\n" //
      + "}");

  JavaFileObject expected1 = forSourceString("OneToNAP_TestGen1", "" //
      + "\n" //
      + "public class OneToNAP_TestGen1 {\n" //
      + "}");

  //WHEN
  //THEN
  Truth.assertAbout(JavaSourceSubjectFactory.javaSource()).that(source) //
      .withCompilerOptions("-Xlint:-processing","-Aincap.mapping.folder=.", "-Aincap.incremental=true") //
      .processedWith(new OneToNAP()) //
      .compilesWithoutError().and().generatesSources(expected0, expected1);
}
 
开发者ID:gradle,项目名称:incap,代码行数:27,代码来源:OneToNAPTest.java

示例6: testOneToOneAP_creates_GeneratedFile_WhenSingleFileToProcess

import com.google.common.truth.Truth; //导入依赖的package包/类
@Test
public void testOneToOneAP_creates_GeneratedFile_WhenSingleFileToProcess() {
  //GIVEN
  source = forSourceString("test.Test", "" //
          + "package test;\n" //
          + "import org.gradle.incap.Annotation1;\n" //
          + "@Annotation1\n" //
          + "public class Test {\n" //
          + "}");
  expected = forSourceString("OneToOneAP_TestGen0", "" //
          + "\n" //
          + "public class OneToOneAP_TestGen0 {\n" //
          + "}");

  //WHEN
  //THEN
  Truth.assertAbout(JavaSourceSubjectFactory.javaSource()).that(source) //
      .withCompilerOptions("-Xlint:-processing","-Aincap.mapping.folder=.", "-Aincap.incremental=true") //
      .processedWith(new OneToOneAP()) //
      .compilesWithoutError().and().generatesSources(expected);
}
 
开发者ID:gradle,项目名称:incap,代码行数:22,代码来源:OneToOneAPTest.java

示例7: testNUnrelatedORToOneAP_creates_GeneratedFiles_WhenSingleFileToProcess

import com.google.common.truth.Truth; //导入依赖的package包/类
@Test
public void testNUnrelatedORToOneAP_creates_GeneratedFiles_WhenSingleFileToProcess() {
  //GIVEN
  JavaFileObject source = forSourceString("test.Test", "" //
      + "package test;\n" //
      + "import org.gradle.incap.Annotation1;\n" //
      + "@Annotation1\n" //
      + "public class Test {\n" //
      + "}");
  JavaFileObject expected0 = forSourceString("NUnrelatedORToOneAP_OR_Gen0", "" //
      + "\n" //
      + "public class NUnrelatedORToOneAP_OR_Gen0 {\n" //
      + "}");

  //WHEN
  //THEN
  Truth.assertAbout(JavaSourceSubjectFactory.javaSource()).that(source) //
      .withCompilerOptions("-Xlint:-processing","-Aincap.mapping.folder=.", "-Aincap.incremental=true") //
      .processedWith(new NUnrelatedORToOneAP()) //
      .compilesWithoutError().and().generatesSources(expected0);
}
 
开发者ID:gradle,项目名称:incap,代码行数:22,代码来源:NUnrelatedORToOneAPTest.java

示例8: testNUnrelatedORToOneAP_creates_GeneratedFiles_WhenTwoFileToProcess

import com.google.common.truth.Truth; //导入依赖的package包/类
@Test
public void testNUnrelatedORToOneAP_creates_GeneratedFiles_WhenTwoFileToProcess() {
  //GIVEN
  JavaFileObject source0 = forSourceString("test.Test0", "" //
      + "package test;\n" //
      + "import org.gradle.incap.Annotation1;\n" //
      + "@Annotation1\n" //
      + "public class Test0 {\n" //
      + "}\n" //
      + "@Annotation1\n" //
      + "class Test1 {\n" //
      + "}");
  JavaFileObject expected = forSourceString("NUnrelatedORToOneAP_OR_Gen0", "" //
      + "\n" //
      + "public class NUnrelatedORToOneAP_OR_Gen0 {\n" //
      + "}");

  //WHEN
  //THEN
  Truth.assertAbout(JavaSourceSubjectFactory.javaSource()).that(source0) //
      .withCompilerOptions("-Xlint:-processing","-Aincap.mapping.folder=.", "-Aincap.incremental=true") //
      .processedWith(new NUnrelatedORToOneAP()) //
      .compilesWithoutError().and().generatesSources(expected);
}
 
开发者ID:gradle,项目名称:incap,代码行数:25,代码来源:NUnrelatedORToOneAPTest.java

示例9: hasArchiveNamed

import com.google.common.truth.Truth; //导入依赖的package包/类
public void hasArchiveNamed(String archive) {
  final Set<String> archives = new HashSet<>();

  // Gather archive names
  (new GatherArchivesYmlReadonlyVisitor(archives)).visitCDepManifestYml(null, actual());

  Truth.assertThat(archives).contains(archive);
}
 
开发者ID:jomof,项目名称:cdep,代码行数:9,代码来源:CDepManifestYmlSubject.java

示例10: viewStateForClassView_throw

import com.google.common.truth.Truth; //导入依赖的package包/类
@Test
public void viewStateForClassView_throw() {
	try {
		getThat(JavaFileObjects.forResource("view/CounterTestView.java"), JavaFileObjects.forResource("presenter/InjectViewStateForClassPresenter.java")).failsToCompile();
		fail();
	} catch (RuntimeException e) {
		Truth.assertThat(e.getLocalizedMessage().contains("must be INTERFACE, or not mark it as"));
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:ViewStateClassTest.java

示例11: testFindLast_longStream

import com.google.common.truth.Truth; //导入依赖的package包/类
public void testFindLast_longStream() {
  Truth.assertThat(findLast(LongStream.of())).isEqualTo(OptionalLong.empty());
  Truth.assertThat(findLast(LongStream.of(1, 2, 3, 4, 5))).isEqualTo(OptionalLong.of(5));

  // test with a large, not-subsized Spliterator
  List<Long> list =
      LongStream.rangeClosed(0, 10000).boxed().collect(Collectors.toCollection(LinkedList::new));
  Truth.assertThat(findLast(list.stream().mapToLong(i -> i))).isEqualTo(OptionalLong.of(10000));

  // no way to find out the stream is empty without walking its spliterator
  Truth.assertThat(findLast(list.stream().mapToLong(i -> i).filter(i -> i < 0)))
      .isEqualTo(OptionalLong.empty());
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:14,代码来源:StreamsTest.java

示例12: testInternalDecode

import com.google.common.truth.Truth; //导入依赖的package包/类
@Test
void testInternalDecode() {
	DefaultDecoder decoder = new DefaultDecoder(new Context(), "mock");
	Node node = new Node();
	decoder.internalDecode(null, node);
	Truth.assertThat(node.getValue("DefaultDecoderFor")).isEqualTo("mock");
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:8,代码来源:DefaultDecoderTest.java

示例13: testRemoveDefaultNode

import com.google.common.truth.Truth; //导入依赖的package包/类
@Test
void testRemoveDefaultNode() {
	List<Node> nodes = Stream.generate(Node::new).limit(5).collect(Collectors.toList());
	nodes.get(0).putValue("DefaultDecoderFor", "mock");
	DefaultDecoder.removeDefaultNode(nodes);
	Truth.assertThat(nodes).hasSize(4);
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:8,代码来源:DefaultDecoderTest.java

示例14: testAllValuesHaveUniqueCodes

import com.google.common.truth.Truth; //导入依赖的package包/类
@Test
void testAllValuesHaveUniqueCodes() {
	Set<Integer> codes = new HashSet<>();
	for (ErrorCode error : ErrorCode.values()) {
		Truth.assertThat(codes).doesNotContain(error.getCode());
		codes.add(error.getCode());
	}
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:9,代码来源:ErrorCodeTest.java

示例15: testHealthCheckContainsAllSystemProperties

import com.google.common.truth.Truth; //导入依赖的package包/类
@Test
void testHealthCheckContainsAllSystemProperties() {
	List<String> systemProperties = System.getProperties().keySet().stream().map(String::valueOf)
			.collect(Collectors.toList());

	Truth.assertThat(service.health().getBody().getSystemProperties()).containsExactlyElementsIn(systemProperties);
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:8,代码来源:HealthCheckControllerTest.java


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