本文整理汇总了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());
}
示例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);
}
示例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...
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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"));
}
}
示例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());
}
示例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");
}
示例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);
}
示例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());
}
}
示例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);
}