### Question:
DateDisplay { DateFormat getDateFormat() { int style = getStyle(isSuffixPresent() ? formatWithoutSuffix() :format); DateFormat dateFormat; if(style < 0) { return new SimpleDateFormat(format, locale); } if(format.endsWith("_t")) { dateFormat = DateFormat.getTimeInstance(style, locale); } else if(format.endsWith("_dt")) { dateFormat = DateFormat.getDateTimeInstance(style, style, locale); } else { dateFormat = DateFormat.getDateInstance(style, locale); } return dateFormat; } DateDisplay();   DateDisplay(String format, Date value, Locale locale);   }### Answer:
@Test public void test_get_style_works_for_styles_with_no_suffix() { Locale locale = defaultLocale(); DateDisplay component = new DateDisplay("medium", new Date(), locale); DateFormat dateFormat = component.getDateFormat(); assertEquals(dateFormat, DateFormat.getDateInstance(DateFormat.MEDIUM, locale)); }
@Test public void test_get_style_works_for_styles_with_time_suffix() { Locale locale = defaultLocale(); DateDisplay component = new DateDisplay("short_t", new Date(), locale); DateFormat dateFormat = component.getDateFormat(); assertEquals(dateFormat, DateFormat.getTimeInstance(DateFormat.SHORT, locale)); }
@Test public void test_get_style_works_for_styles_with_date_time_suffix() { Locale locale = defaultLocale(); DateDisplay component = new DateDisplay("long_dt", new Date(), locale); DateFormat dateFormat = component.getDateFormat(); assertEquals(dateFormat, DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale)); }
@Test public void test_get_style_works_for_patterns() { Locale locale = defaultLocale(); String pattern = "dd/mm/yyyy"; DateDisplay component = new DateDisplay(pattern, new Date(), locale); DateFormat dateFormat = component.getDateFormat(); assertEquals(dateFormat, new SimpleDateFormat(pattern, locale)); }
@Test public void test_get_style_works_for_patterns_with_underscores() { Locale locale = defaultLocale(); String pattern = "dd_mm_yyyy"; DateDisplay component = new DateDisplay(pattern, new Date(), locale); DateFormat dateFormat = component.getDateFormat(); assertEquals(dateFormat, new SimpleDateFormat(pattern, locale)); }