### Question:
ControllerUtils { public static String getDeviceAppropriateView(HttpServletRequest request, String defaultView, String mobileView) { String viewName = null; if (ControllerUtils.isMobileDevice(request)) { log.debug("mobile device detected - viewing default mobile page template"); viewName = mobileView; } else { log.debug("non-mobile device detected - viewing regular page layout"); viewName = defaultView; } log.debug("viewName: " + viewName); return viewName; }  static boolean isMobileDevice(HttpServletRequest request); static String getDeviceAppropriateView(HttpServletRequest request, String defaultView, String mobileView); static void addNavItemsToModel(String view, Model model, String referringPageId, User user); static void addNavItemsToModel(String view, Model model, String referringPageId, User user, boolean addStore); static NavigationMenu getTopMenu(String view, String referringPageId, User user, boolean addStoreLink); static String getDisplayName(User user);  }### Answer:
@Test public void testGetDeviceAppropriateView_defaultView() { String defaultView = "defaultView"; String mobileView = "mobileView"; request.addHeader("User-Agent", "MSIE"); request.setAttribute(DeviceUtils.CURRENT_DEVICE_ATTRIBUTE, deviceResolver.resolveDevice(request)); assertThat(ControllerUtils.getDeviceAppropriateView(request, defaultView, mobileView), is(defaultView)); }
@Test public void testGetDeviceAppropriateView_mobileView() { String defaultView = "defaultView"; String mobileView = "mobileView"; request.addHeader("User-Agent", "Blackberry"); request.setAttribute(DeviceUtils.CURRENT_DEVICE_ATTRIBUTE, deviceResolver.resolveDevice(request)); assertThat(ControllerUtils.getDeviceAppropriateView(request, defaultView, mobileView), is(mobileView)); }