### Question:
ApplicationModel { public boolean authorize(final APISession session) { for (final Profile userProfile : getUserProfiles(session)) { if (userProfile.getId() == application.getProfileId()) { return true; } } return false; } ApplicationModel(
            final ApplicationAPI applicationApi,
            final PageAPI pageApi,
            final ProfileAPI profileApi,
            final Application application,
            final MenuFactory factory); long getId(); String getApplicationLayoutName(); String getApplicationThemeName(); Long getApplicationThemeId(); String getApplicationHomePage(); boolean hasPage(final String pageToken); boolean authorize(final APISession session); boolean hasProfileMapped(); Page getCustomPage(final String pageToken); List<Menu> getMenuList();  }### Answer:
@Test public void should_authorize_a_user_with_the_configured_application_profile() throws Exception { final ProfileImpl profile1 = new ProfileImpl("user"); profile1.setId(1L); final ProfileImpl profile2 = new ProfileImpl("administrator"); profile1.setId(2L); given(profileApi.getProfilesForUser(1L, 0, Integer.MAX_VALUE, ProfileCriterion.ID_ASC)) .willReturn(asList((Profile) profile1, profile2)); given(session.getUserId()).willReturn(1L); application.setProfileId(2L); assertThat(model.authorize(session)).isTrue(); }
@Test public void should_not_authorize_a_user_without_the_configured_application_profile() throws Exception { final ProfileImpl profile1 = new ProfileImpl("user"); profile1.setId(1L); final ProfileImpl profile2 = new ProfileImpl("administrator"); profile1.setId(2L); given(profileApi.getProfilesForUser(1L, 0, Integer.MAX_VALUE, ProfileCriterion.ID_ASC)) .willReturn(asList((Profile) profile1, profile2)); given(session.getUserId()).willReturn(1L); application.setProfileId(3L); assertThat(model.authorize(session)).isFalse(); }