private void assertToArray(TypeConverter converter, Object... values) { Object[] array = converter.toArray(createList(values)); Assert.assertEquals(array.length, values.length); for (int i = 0; i < values.length; i++) { Assert.assertEquals(array[i], values[i]); } }
@Test public void testBytesConverter() { ModelNode description = createDescription(ModelType.BYTES); TypeConverter converter = getConverter(description); Assert.assertEquals(ArrayType.getPrimitiveArrayType(byte[].class), converter.getOpenType()); Assert.assertTrue( Arrays.equals( new byte[] {1, 2, 3}, assertCast( byte[].class, converter.fromModelNode(new ModelNode().set(new byte[] {1, 2, 3}))))); Assert.assertTrue( Arrays.equals(new byte[] {1, 2, 3}, converter.toModelNode(new byte[] {1, 2, 3}).asBytes())); byte[][] bytes = assertCast( byte[][].class, converter.toArray(createList(new byte[] {1, 2, 3}, new byte[] {4, 5, 6}))); Assert.assertEquals(2, bytes.length); Assert.assertTrue(Arrays.equals(new byte[] {1, 2, 3}, bytes[0])); Assert.assertTrue(Arrays.equals(new byte[] {4, 5, 6}, bytes[1])); }