/** Populates the flight extra content */ @Override public void populate(final Object source, final ContentViewData target) { // REVISIT:Changed to BasePackage final BasePackage packageModel = packageCartService.getBasePackage(); final FlightExtraFacilityStore flightExtraStore = sessionService.getAttribute(SessionObjectKeys.FLIGHT_EXTRA_FACILITY_STORE); String flightMealCode = StringUtils.EMPTY; if (flightExtraStore != null) { String inventoryCode = StringUtils.EMPTY; final Map<String, List<ExtraFacility>> validExtraFacilitiesMap = flightExtraStore.getExtraFacilityFromAllLegsBasedOnCabinClass( packageModel.getId(), PackageUtilityService.getCabinClass(packageModel)); for (final List<ExtraFacility> eachEntry : validExtraFacilitiesMap.values()) { inventoryCode = eachEntry.get(0).getExtraFacilityCategory().getInventoryCode(); final String extraCode = eachEntry.get(0).getExtraFacilityCode(); final String corporateCode = eachEntry.get(0).getCorporateCode(); final List<DynamicContentConfigModel> dynamicContents = genericContentService.getDynamicContentConfig(inventoryCode, extraCode, corporateCode); getDynamicContents(target, dynamicContents); } if (StringUtils.equalsIgnoreCase(inventoryCode, "FM")) { flightMealCode = inventoryCode; } final Leg leg = getFlightLeg(packageModel); populateContentForShortHaul(target, leg); populateMealContent(flightMealCode, target); } }
@RequestMapping(method = RequestMethod.GET) public String showForm( @RequestParam(value = ACTIVE_CATEGORY, required = true) final String activeCategory, @RequestParam(value = "agent", required = true) final String agentId, @RequestParam(value = SEND_STATUS, required = false) final String viewStatus, final Model model) throws CMSItemNotFoundException, YFormServiceException, InvalidAttributeValueException { storeCmsPageInModel(model, getContentPageForLabelOrId(CONTACT_AGENT_FORM_CMS_PAGE)); if (SEND.equals(viewStatus)) { final String dataId = sessionService.getAttribute( FinancialacceleratorstorefrontConstants.FINANCIAL_FIND_AGENT_FORM_ID); if (StringUtils.isNotEmpty(dataId)) { final YFormDataData yfdd = getYformFacade().getYFormData(dataId, YFormDataTypeEnum.DATA); agentFacade.sendMail(yfdd.getContent()); sessionService.removeAttribute( FinancialacceleratorstorefrontConstants.FINANCIAL_FIND_AGENT_FORM_ID); model.addAttribute(THANK_YOU, Boolean.TRUE); } else { throw new InvalidAttributeValueException( "Can't upload yFormData. Attribute 'financialFindAgentForm' doesn't exist in session."); } } if (StringUtils.isNotBlank(agentId)) { final AgentData agent = getAgentFacade().getAgentByUid(agentId); model.addAttribute(AGENT_DATA, agent); model.addAttribute(ACTIVE_CATEGORY, activeCategory); } return ControllerConstants.Views.Pages.Agent.ContactAgentForm; }
@Override public ConfigurationProvider getProvider() { ConfigurationProvider provider = sessionService.getAttribute(SESSION_CACHE_KEY); if (provider == null) { provider = createProviderInstance(); sessionService.setAttribute(SESSION_CACHE_KEY, provider); } return provider; }
@Test public void testGetCurrentJavaCurrencyWithNonExistentJavaCurrency() { final CurrencyModel currency1 = new CurrencyModel(); currency1.setIsocode("BLABLA"); when(sessionService.getAttribute(I18NConstants.CURRENCY_SESSION_ATTR_KEY)) .thenReturn(currency1); try { i18NService.getCurrentJavaCurrency(); fail(); } catch (final ConfigurationException e) { // ok } verify(sessionService, times(1)).getAttribute(Mockito.anyString()); }
@Test public void testGetCurrentTimeZone() { final TimeZone timeZone = TimeZone.getTimeZone("America/Los_Angeles"); when(sessionService.getAttribute(I18NConstants.TIMEZONE_SESSION_ATTR_KEY)).thenReturn(timeZone); final TimeZone currentTimeZone = i18NService.getCurrentTimeZone(); assertEquals( "Wrong current time zone ID! Should be: '" + timeZone.getID() + "' but was: '" + currentTimeZone.getID() + "'.", timeZone.getID(), currentTimeZone.getID()); verify(sessionService, times(1)).getAttribute(Mockito.anyString()); }
@Test public void removeAllWithoutTransaction() throws Exception { // given doReturn(sessionService).when(modelService).lookupSessionService(); doReturn(interceptorRegistry).when(modelService).lookupInterceptorRegistry(); doReturn(converterRegistry).when(modelService).lookupConverterRegistry(); given(converterRegistry.getModelConverterByModelType((Class) anyObject())) .willReturn(modelConverter); given(modelConverter.getType(model1)).willReturn("ItemModel"); given(sessionService.getAttribute(DefaultModelService.ENABLE_TRANSACTIONAL_SAVES)) .willReturn(Boolean.FALSE); // when (execute 2 remove* methods) modelService.remove(model1); modelService.removeAll(Arrays.asList(model1, model2)); // then (should be 0 interactions with transaction mock) verify(transaction, times(0)).execute((TransactionCallback) anyObject()); }
@Test public void shouldExecuteSaveVaragsObjectsInTransactionWhenGlobalTransactionFlagIsFalseButLocallyTransactionsAreEnabled() throws Exception { // given modelService.setTransactional(false); doReturn(sessionService).when(modelService).lookupSessionService(); given(sessionService.getAttribute(DefaultModelService.ENABLE_TRANSACTIONAL_SAVES)) .willReturn(Boolean.TRUE); // when (execute all 4 save* methods) modelService.save(model1); modelService.saveAll(model1, model2); modelService.saveAll(Collections.singletonList(model1)); modelService.saveAll(); // then (should be 4 interactions with transaction mock) verify(transaction, times(4)).execute((TransactionCallback) anyObject()); }
@Test public void testGetCurrentJavaCurrency() { final CurrencyModel currency1 = new CurrencyModel(); currency1.setIsocode("USD"); when(sessionService.getAttribute(I18NConstants.CURRENCY_SESSION_ATTR_KEY)) .thenReturn(currency1); final Currency currentJavaCurrency = i18NService.getCurrentJavaCurrency(); assertEquals( "Wrong current java currency isocode! Should be: '" + currency1.getIsocode() + "' but was: '" + currentJavaCurrency.getCurrencyCode() + "'.", currency1.getIsocode(), currentJavaCurrency.getCurrencyCode()); verify(sessionService, times(1)).getAttribute(Mockito.anyString()); }
@Test public void shouldExecuteSaveVaragsObjectsWithoutTransactionWhenGlobalTransactionFlagIsTrueButLocallyTransactionsAreDisabled() throws Exception { // given modelService.setTransactional(true); doReturn(sessionService).when(modelService).lookupSessionService(); doReturn(interceptorRegistry).when(modelService).lookupInterceptorRegistry(); doReturn(converterRegistry).when(modelService).lookupConverterRegistry(); given(converterRegistry.getModelConverterByModelType((Class) anyObject())) .willReturn(modelConverter); given(modelConverter.getType(model1)).willReturn("ItemModel"); given(sessionService.getAttribute(DefaultModelService.ENABLE_TRANSACTIONAL_SAVES)) .willReturn(Boolean.FALSE); // when (execute all 4 save* methods) modelService.save(model1); modelService.saveAll(model1, model2); modelService.saveAll(Collections.singletonList(model1)); modelService.saveAll(); // then (should be 0 interactions with transaction mock) verify(transaction, times(0)).execute((TransactionCallback) anyObject()); }
@Test public void testIsLocalizationFallbackEnabled() { // both attributes are set to true when(sessionService.getAttribute(AbstractItemModel.LANGUAGE_FALLBACK_ENABLED_SERVICE_LAYER)) .thenReturn(Boolean.TRUE); when(sessionService.getAttribute(I18NConstants.LANGUAGE_FALLBACK_ENABLED)) .thenReturn(Boolean.TRUE); assertTrue( "The localization fallback mechanism should be enabled!", i18NService.isLocalizationFallbackEnabled()); verify(sessionService, times(2)).getAttribute(Mockito.anyString()); Mockito.reset(sessionService); // servicelayer attribute is set to false when(sessionService.getAttribute(AbstractItemModel.LANGUAGE_FALLBACK_ENABLED_SERVICE_LAYER)) .thenReturn(Boolean.FALSE); when(sessionService.getAttribute(I18NConstants.LANGUAGE_FALLBACK_ENABLED)) .thenReturn(Boolean.TRUE); assertFalse( "The localization fallback mechanism should be disabled!", i18NService.isLocalizationFallbackEnabled()); verify(sessionService, times(1)).getAttribute(Mockito.anyString()); Mockito.reset(sessionService); // jalo attribute is set to false when(sessionService.getAttribute(AbstractItemModel.LANGUAGE_FALLBACK_ENABLED_SERVICE_LAYER)) .thenReturn(Boolean.TRUE); when(sessionService.getAttribute(I18NConstants.LANGUAGE_FALLBACK_ENABLED)) .thenReturn(Boolean.FALSE); assertFalse( "The localization fallback mechanism should be disabled!", i18NService.isLocalizationFallbackEnabled()); verify(sessionService, times(2)).getAttribute(Mockito.anyString()); }