@Test public void testDecodeFromString() { ClassDescriptor<TypeInfo> desc = new ClassDescriptor<>(TypeInfo.class); assertEquals("asd", decoder.decodeFromString(desc.getField("string"), "asd")); assertEquals(1, decoder.decodeFromString(desc.getField("singleInt"), "1")); assertEquals(true, decoder.decodeFromString(desc.getField("singleBoolean"), "true")); assertEquals(false, decoder.decodeFromString(desc.getField("singleBoolean"), "false")); }
@Test public void testDecodeFromMultiString() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, NoSuchFieldException { ClassDescriptor<TypeInfo> desc = new ClassDescriptor<>(TypeInfo.class); List<String> stringList = new ArrayList<>(); stringList.add("asd"); stringList.add("bds"); assertEquals( stringList, decoder.decodeFromMultiString(desc.getField("strings"), new String[] {"asd", "bds"})); List<Integer> ints = new ArrayList<>(); ints.add(1); ints.add(3); assertEquals( ints, decoder.decodeFromMultiString(desc.getField("ints"), new String[] {"1", "3"})); }