### Question:
TLVSerializer { private static ByteArrayOutputStream serializeMultipleResource(LWM2MResource resource, ByteArrayOutputStream stream) { ByteArrayOutputStream nestedStream = new ByteArrayOutputStream(); List<LWM2MResourceInstance> nestedInstances = resource.getNestedInstances(); for (int index=0; index<nestedInstances.size(); index++) { LWM2MResourceInstance nested = nestedInstances.get(index); int id = nested.getId().stringValue() == null ? index : nested.getId().intValue(); serializeResourceInstance(id, nested, nestedStream); } byte[] nestedValue = nestedStream.toByteArray(); return serializeTILV(TYPE_MULTIPLE_RESOURCE, resource.getId().intValue(), nestedValue, stream); }  static byte[] serialize(LWM2MObjectInstance... objects); static byte[] serialize(LWM2MResource... resources); static byte[] serializeObjectInstances(List<LWM2MObjectInstance> objects); static byte[] serializeResources(List<LWM2MResource> resources);  }### Answer:
@Test public void serializeMultipleResource() throws Exception { LWM2MResourceInstance internalBattery = new LWM2MResourceInstance(LWM2MID.create(), 0x01); LWM2MResourceInstance usbBattery = new LWM2MResourceInstance(LWM2MID.create(), 0x05); LWM2MResource power = new LWM2MResource(LWM2MID.from(6), Arrays.asList(internalBattery, usbBattery)); byte[] powerTLV = TLVSerializer.serialize(power); assertEquals(8, powerTLV.length); assertArrayEquals( new byte[] { (byte) 0b10_0_00_110, (byte) 6, (byte) 0b01_0_00_001, (byte) 0, (byte) 0x01, (byte) 0b01_0_00_001, (byte) 1, (byte) 0x05, }, powerTLV); }