Introduction to Pants Build Tool (#14517)
* Introduction to Pants Build Tool * Introduction to Pants Build Tool * Introduction to Pants Build Tool * Introduction to Pants Build Tool * Introduction to Pants Build Tool
This commit is contained in:
30
pants/test/com/baeldung/hellopant/GuavaUnitTest.java
Normal file
30
pants/test/com/baeldung/hellopant/GuavaUnitTest.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.baeldung.hellopant;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.io.Resources;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import org.junit.Test;
|
||||
|
||||
public class GuavaUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenConvertListToStringAndSkipNull_thenConverted() {
|
||||
final List<String> names = Lists.newArrayList("John", null, "Jane", "Adam", "Tom");
|
||||
final String result = Joiner.on(",").skipNulls().join(names);
|
||||
|
||||
assertEquals(result, "John,Jane,Adam,Tom");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGettingTextFromAResourceFile_thenJoined() throws IOException {
|
||||
String world = Resources.toString(Resources.getResource(GuavaUnitTest.class, "word.txt"), Charsets.UTF_8).strip();
|
||||
String result = Joiner.on(" ").join("Hello", world);
|
||||
assertEquals(result, "Hello from Us");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user