Skip to content

Commit 1989eb4

Browse files
committed
Create StringToMultiValueConverterTest.java
1 parent 82154be commit 1989eb4

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package io.microsphere.convert.multiple;
2+
3+
import org.junit.jupiter.api.BeforeEach;
4+
import org.junit.jupiter.api.Test;
5+
6+
import static io.microsphere.util.ArrayUtils.ofArray;
7+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
8+
9+
/**
10+
* {@link StringToMultiValueConverter} Test
11+
*
12+
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
13+
* @see StringToMultiValueConverter
14+
* @since
15+
*/
16+
public class StringToMultiValueConverterTest {
17+
18+
private StringToMultiValueConverter converter;
19+
20+
@BeforeEach
21+
public void init() {
22+
converter = new StringToMultiValueConverter() {
23+
@Override
24+
public boolean accept(Class<String> sourceType, Class<?> multiValueType) {
25+
return false;
26+
}
27+
28+
@Override
29+
public Object convert(String[] segments, int size, Class<?> targetType, Class<?> elementType) {
30+
return segments;
31+
}
32+
};
33+
}
34+
35+
@Test
36+
public void testConvert() {
37+
String source = "";
38+
assertArrayEquals(ofArray(source), (String[]) converter.convert(source, null, null));
39+
40+
source = "a,b,c";
41+
assertArrayEquals(ofArray("a", "b", "c"), (String[]) converter.convert(source, null, null));
42+
}
43+
44+
@Test
45+
public void testConvertOnNull() {
46+
assertArrayEquals(ofArray((String) null), (String[]) converter.convert(null, null, null));
47+
}
48+
}

0 commit comments

Comments
 (0)