felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1770414 - /felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterTest.java
Date Fri, 18 Nov 2016 17:09:55 GMT
Author: davidb
Date: Fri Nov 18 17:09:55 2016
New Revision: 1770414

URL: http://svn.apache.org/viewvc?rev=1770414&view=rev
Log:
Felix Converter - Additional Unit Test

Modified:
    felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterTest.java

Modified: felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterTest.java?rev=1770414&r1=1770413&r2=1770414&view=diff
==============================================================================
--- felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterTest.java
(original)
+++ felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterTest.java
Fri Nov 18 17:09:55 2016
@@ -308,7 +308,7 @@ public class ConverterTest {
     }
 
     @Test
-    public void testCustomStringArrayConverstion() {
+    public void testCustomStringArrayConversion() {
         ConverterBuilder cb = converter.newConverterBuilder();
         cb.rule(String[].class, String.class,
                 v -> Stream.of(v).collect(Collectors.joining(",")),
@@ -321,6 +321,20 @@ public class ConverterTest {
     }
 
     @Test
+    public void testCustomIntArrayConversion() {
+        ConverterBuilder cb = converter.newConverterBuilder();
+        cb.rule(int[].class, String.class,
+                v -> Arrays.stream(v).mapToObj(Integer::toString).collect(Collectors.joining(",")),
+                v -> Arrays.stream(v.split(",")).mapToInt(Integer::parseInt).toArray());
+        Converter adapted = cb.build();
+
+        int[] ia = {1, 2};
+        assertEquals("1,2", adapted.convert(ia).to(String.class));
+        assertArrayEquals(ia, adapted.convert("1,2").to(int[].class));
+
+    }
+
+    @Test
     public void testUUIDConversion() {
         UUID uuid = UUID.randomUUID();
         String s = converter.convert(uuid).to(String.class);



Mime
View raw message