@Test public void testGetLabelForEvent() { Event noType = mockEventType(EventType.NONE); assertEquals(EventHelper.generateLabelForEvent(noType), EventHelper.WEEKLESS_LABEL); Event preseason = mockEventType(EventType.PRESEASON); assertEquals(EventHelper.generateLabelForEvent(preseason), EventHelper.PRESEASON_LABEL); Event offseason = mockEventType(EventType.OFFSEASON); when(offseason.getFormattedStartDate()).thenReturn(new Date(115, 4, 2)); assertEquals(EventHelper.generateLabelForEvent(offseason), "May Offseason Events"); Event cmpDivision = mockEventType(EventType.CMP_DIVISION); assertEquals(EventHelper.generateLabelForEvent(cmpDivision), EventHelper.CHAMPIONSHIP_LABEL); Event cmpFinals = mockEventType(EventType.CMP_FINALS); assertEquals(EventHelper.generateLabelForEvent(cmpFinals), EventHelper.CHAMPIONSHIP_LABEL); Event regional = mockRegularEvent(EventType.REGIONAL, 2015, 5); assertEquals(EventHelper.generateLabelForEvent(regional), "Week 5"); Event district = mockRegularEvent(EventType.DISTRICT, 2015, 2); assertEquals(EventHelper.generateLabelForEvent(district), "Week 2"); Event districtCmp = mockRegularEvent(EventType.DISTRICT_CMP, 2012, 1); assertEquals(EventHelper.generateLabelForEvent(districtCmp), "Week 1"); Event scmb = ModelMaker.getModel(Event.class, "2016scmb"); assertEquals(EventHelper.generateLabelForEvent(scmb), "Week 0.5"); Event regional2016 = mockRegularEvent(EventType.REGIONAL, 2016, 2); assertEquals(EventHelper.generateLabelForEvent(regional2016), "Week 1"); Event district2016 = mockRegularEvent(EventType.DISTRICT, 2016, 4); assertEquals(EventHelper.generateLabelForEvent(district2016), "Week 3"); Event districtCmp2016 = mockRegularEvent(EventType.DISTRICT_CMP, 2016, 7); assertEquals(EventHelper.generateLabelForEvent(districtCmp2016), "Week 6"); }
public static String generateLabelForEvent(Event e) { switch (e.getEventTypeEnum()) { case CMP_DIVISION: case CMP_FINALS: if (e.getYear() >= 2017 && e.getCity() != null) { return String.format(CITY_CHAMPIONSHIP_LABEL, e.getCity()); } else { return CHAMPIONSHIP_LABEL; } case REGIONAL: case DISTRICT: case DISTRICT_CMP: case DCMP_DIVISION: @Nullable Integer week = e.getWeek(); if (e.getYear() == 2016) { if (week == null) { return String.format(Locale.US, REGIONAL_LABEL, 0); } else if ("2016scmb".equals(e.getKey())) { return String.format(Locale.US, FLOAT_REGIONAL_LABEL, 0.5); } else { return String.format(Locale.US, REGIONAL_LABEL, week - 1); } } else if (week != null){ return String.format(Locale.US, REGIONAL_LABEL, week); } else { return String.format(Locale.US, REGIONAL_LABEL, 0); } case OFFSEASON: String month = ThreadSafeFormatters.renderEventMonth(e.getFormattedStartDate()); return String.format(OFFSEASON_LABEL, month); case PRESEASON: return PRESEASON_LABEL; default: return WEEKLESS_LABEL; } }
EventHelper { public static String generateLabelForEvent(Event e) { switch (e.getEventTypeEnum()) { case CMP_DIVISION: case CMP_FINALS: if (e.getYear() >= 2017 && e.getCity() != null) { return String.format(CITY_CHAMPIONSHIP_LABEL, e.getCity()); } else { return CHAMPIONSHIP_LABEL; } case REGIONAL: case DISTRICT: case DISTRICT_CMP: case DCMP_DIVISION: @Nullable Integer week = e.getWeek(); if (e.getYear() == 2016) { if (week == null) { return String.format(Locale.US, REGIONAL_LABEL, 0); } else if ("2016scmb".equals(e.getKey())) { return String.format(Locale.US, FLOAT_REGIONAL_LABEL, 0.5); } else { return String.format(Locale.US, REGIONAL_LABEL, week - 1); } } else if (week != null){ return String.format(Locale.US, REGIONAL_LABEL, week); } else { return String.format(Locale.US, REGIONAL_LABEL, 0); } case OFFSEASON: String month = ThreadSafeFormatters.renderEventMonth(e.getFormattedStartDate()); return String.format(OFFSEASON_LABEL, month); case PRESEASON: return PRESEASON_LABEL; default: return WEEKLESS_LABEL; } } }
EventHelper { public static String generateLabelForEvent(Event e) { switch (e.getEventTypeEnum()) { case CMP_DIVISION: case CMP_FINALS: if (e.getYear() >= 2017 && e.getCity() != null) { return String.format(CITY_CHAMPIONSHIP_LABEL, e.getCity()); } else { return CHAMPIONSHIP_LABEL; } case REGIONAL: case DISTRICT: case DISTRICT_CMP: case DCMP_DIVISION: @Nullable Integer week = e.getWeek(); if (e.getYear() == 2016) { if (week == null) { return String.format(Locale.US, REGIONAL_LABEL, 0); } else if ("2016scmb".equals(e.getKey())) { return String.format(Locale.US, FLOAT_REGIONAL_LABEL, 0.5); } else { return String.format(Locale.US, REGIONAL_LABEL, week - 1); } } else if (week != null){ return String.format(Locale.US, REGIONAL_LABEL, week); } else { return String.format(Locale.US, REGIONAL_LABEL, 0); } case OFFSEASON: String month = ThreadSafeFormatters.renderEventMonth(e.getFormattedStartDate()); return String.format(OFFSEASON_LABEL, month); case PRESEASON: return PRESEASON_LABEL; default: return WEEKLESS_LABEL; } } private  EventHelper(); }
EventHelper { public static String generateLabelForEvent(Event e) { switch (e.getEventTypeEnum()) { case CMP_DIVISION: case CMP_FINALS: if (e.getYear() >= 2017 && e.getCity() != null) { return String.format(CITY_CHAMPIONSHIP_LABEL, e.getCity()); } else { return CHAMPIONSHIP_LABEL; } case REGIONAL: case DISTRICT: case DISTRICT_CMP: case DCMP_DIVISION: @Nullable Integer week = e.getWeek(); if (e.getYear() == 2016) { if (week == null) { return String.format(Locale.US, REGIONAL_LABEL, 0); } else if ("2016scmb".equals(e.getKey())) { return String.format(Locale.US, FLOAT_REGIONAL_LABEL, 0.5); } else { return String.format(Locale.US, REGIONAL_LABEL, week - 1); } } else if (week != null){ return String.format(Locale.US, REGIONAL_LABEL, week); } else { return String.format(Locale.US, REGIONAL_LABEL, 0); } case OFFSEASON: String month = ThreadSafeFormatters.renderEventMonth(e.getFormattedStartDate()); return String.format(OFFSEASON_LABEL, month); case PRESEASON: return PRESEASON_LABEL; default: return WEEKLESS_LABEL; } } private  EventHelper(); static boolean validateEventKey(String key); static String shortName(String eventName); static int getYear(String eventKey); static int getYearWeek(Date date); static int competitionWeek(Date date); static String generateLabelForEvent(Event e); static String weekLabelFromNum(int year, @Nullable Integer weekNum); static int weekNumFromLabel(int year, String label); static void renderEventListForTeam(Context context,List<Event> events, List<Object> output); static void renderEventListForWeek(Context context, List<Event> events, List<Object> output); static void renderEventListForDistrict(
            Context context,
            List<Event> events,
            List<Object> output); static String getDateString(Date startDate, Date endDate); static String getShortCodeForEventKey(String eventKey); static String getEventCode(String matchOrEventOrDistrictKey); }
EventHelper { public static String generateLabelForEvent(Event e) { switch (e.getEventTypeEnum()) { case CMP_DIVISION: case CMP_FINALS: if (e.getYear() >= 2017 && e.getCity() != null) { return String.format(CITY_CHAMPIONSHIP_LABEL, e.getCity()); } else { return CHAMPIONSHIP_LABEL; } case REGIONAL: case DISTRICT: case DISTRICT_CMP: case DCMP_DIVISION: @Nullable Integer week = e.getWeek(); if (e.getYear() == 2016) { if (week == null) { return String.format(Locale.US, REGIONAL_LABEL, 0); } else if ("2016scmb".equals(e.getKey())) { return String.format(Locale.US, FLOAT_REGIONAL_LABEL, 0.5); } else { return String.format(Locale.US, REGIONAL_LABEL, week - 1); } } else if (week != null){ return String.format(Locale.US, REGIONAL_LABEL, week); } else { return String.format(Locale.US, REGIONAL_LABEL, 0); } case OFFSEASON: String month = ThreadSafeFormatters.renderEventMonth(e.getFormattedStartDate()); return String.format(OFFSEASON_LABEL, month); case PRESEASON: return PRESEASON_LABEL; default: return WEEKLESS_LABEL; } } private  EventHelper(); static boolean validateEventKey(String key); static String shortName(String eventName); static int getYear(String eventKey); static int getYearWeek(Date date); static int competitionWeek(Date date); static String generateLabelForEvent(Event e); static String weekLabelFromNum(int year, @Nullable Integer weekNum); static int weekNumFromLabel(int year, String label); static void renderEventListForTeam(Context context,List<Event> events, List<Object> output); static void renderEventListForWeek(Context context, List<Event> events, List<Object> output); static void renderEventListForDistrict(
            Context context,
            List<Event> events,
            List<Object> output); static String getDateString(Date startDate, Date endDate); static String getShortCodeForEventKey(String eventKey); static String getEventCode(String matchOrEventOrDistrictKey); static final String CHAMPIONSHIP_LABEL; static final String CITY_CHAMPIONSHIP_LABEL; static final String REGIONAL_LABEL; static final String FLOAT_REGIONAL_LABEL; static final String WEEKLESS_LABEL; static final String OFFSEASON_LABEL; static final String PRESEASON_LABEL; }