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