### Question:
CalendarEncoder extends Encoder { private void encodeCategories(Element p, List<String> categories) { if (categories != null && !categories.isEmpty()) { Element ce = DOMUtils.createElement(p, ASCalendar.CATEGORIES.asASValue()); for (String category : categories) { s(ce, ASCalendar.CATEGORY.asASValue(), category); } } } @Inject protected  CalendarEncoder(TimeZoneEncoder timeZoneEncoder, TimeZoneConverter timeZoneConverter); void encode(Device device, Element p, IApplicationData data, boolean isResponse); Element encodedApplicationData(Device device, IApplicationData data, boolean isResponse);  }### Answer:
@Test public void testEncodeCategories() throws Exception { MSEvent msEvent = getFakeMSEvent(defaultTimeZone); msEvent.setCategories(ImmutableList.of("Cat1", "Cat2")); String actual = encodeMSEventAsString(msEvent); StringBuilder expected = new StringBuilder(); expected.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); expected.append("<ApplicationData xmlns=\"test\">"); expected.append("<Calendar:TimeZone>" + AS_GMT + "</Calendar:TimeZone>"); expected.append("<Calendar:DTStamp>19700101T000000Z</Calendar:DTStamp>"); expected.append("<Calendar:UID>FAC000123D</Calendar:UID>"); expected.append("<AirSyncBase:Body>"); expected.append("<AirSyncBase:Type>1</AirSyncBase:Type>"); expected.append("<AirSyncBase:EstimatedDataSize>0</AirSyncBase:EstimatedDataSize>"); expected.append("</AirSyncBase:Body>"); expected.append("<Calendar:Categories>"); expected.append("<Calendar:Category>Cat1</Calendar:Category>"); expected.append("<Calendar:Category>Cat2</Calendar:Category>"); expected.append("</Calendar:Categories>"); expected.append("<Calendar:Sensitivity>0</Calendar:Sensitivity>"); expected.append("<Calendar:BusyStatus>0</Calendar:BusyStatus>"); expected.append("<Calendar:AllDayEvent>0</Calendar:AllDayEvent>"); expected.append("<Calendar:MeetingStatus>0</Calendar:MeetingStatus>"); expected.append("<AirSyncBase:NativeBodyType>1</AirSyncBase:NativeBodyType>"); expected.append("</ApplicationData>"); assertThat(actual).isEqualTo(expected.toString()); }