<dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>30.1-jre</version> <scope>test</scope> </dependency> <dependency> <groupId>org.easytesting</groupId> <artifactId>fest-testng-2.0-SNAPSHOT</artifactId> <version>RELEASE</version> <scope>test</scope> </dependency> @Test public void testImmutableList() { ImmutableList<String> list = ImmutableList.of("apple", "banana", "orange"); assertThat(list).contains("apple").doesNotContain("grape").hasSize(3); } @Test public void testImmutableMap() { ImmutableMap<Integer, String> map = ImmutableMap.of(1, "one", 2, "two", 3, "three"); assertThat(map).containsEntry(1, "one").doesNotContainKey(4).containsValue("two"); } @Test public void testOptional() { Optional<String> optional = Optional.of("value"); assertThat(optional).contains("value").isPresent(); }


上一篇:
下一篇:
切换中文