ActionButtonGroupsParser { @NonNull public static Map<String, NotificationActionButtonGroup> fromXml(@NonNull Context context, @XmlRes int resource) { XmlResourceParser parser; try { parser = context.getResources().getXml(resource); return parseGroups(context, parser); } catch (IOException | XmlPullParserException | Resources.NotFoundException | NullPointerException e) { Logger.error(e, "Failed to parse NotificationActionButtonGroups."); return new HashMap<>(); } }  @NonNull static Map<String, NotificationActionButtonGroup> fromXml(@NonNull Context context, @XmlRes int resource);  }
@Test @SuppressWarnings("ResourceType") public void testLoadXmlMissingResource() { Map<String, NotificationActionButtonGroup> groups = ActionButtonGroupsParser.fromXml(context, -1); assertTrue(groups.isEmpty()); }
@Test public void testDefaultGroups() { Map<String, NotificationActionButtonGroup> groups = ActionButtonGroupsParser.fromXml(context, R.xml.ua_notification_buttons); assertEquals(37, groups.size()); NotificationActionButtonGroup yesNoGroup = groups.get("ua_yes_no_foreground"); assertEquals(2, yesNoGroup.getNotificationActionButtons().size()); NotificationActionButton yes = yesNoGroup.getNotificationActionButtons().get(0); assertEquals("yes", yes.getId()); assertEquals("Yes", yes.getLabel(context)); assertEquals(R.drawable.ua_ic_notification_button_accept, yes.getIcon()); assertTrue(yes.isForegroundAction()); NotificationActionButton no = yesNoGroup.getNotificationActionButtons().get(1); assertEquals("no", no.getId()); assertEquals("No", no.getLabel(context)); assertEquals(R.drawable.ua_ic_notification_button_decline, no.getIcon()); assertFalse(no.isForegroundAction()); }