@Test public void shouldUpdateCompanyNameAndTopBarThemeWhenInformationUpdated() throws Exception { SettingService settingService = mock(SettingService.class); FileService fileService = mock(FileService.class); UploadService uploadService = mock(UploadService.class); InitParams initParams = new InitParams(); ValueParam companyName = new ValueParam(); companyName.setName(BrandingServiceImpl.BRANDING_COMPANY_NAME_INIT_PARAM); companyName.setValue("Default Company Name"); initParams.addParam(companyName); BrandingService brandingService = new BrandingServiceImpl(initParams, settingService, fileService, uploadService); Branding newBranding = new Branding(); newBranding.setCompanyName("New Company Name"); newBranding.setTopBarTheme("Pink"); ArgumentCaptor<Context> settingContext = ArgumentCaptor.forClass(Context.class); ArgumentCaptor<Scope> settingScope = ArgumentCaptor.forClass(Scope.class); ArgumentCaptor<String> settingKey = ArgumentCaptor.forClass(String.class); ArgumentCaptor<SettingValue> settingValue = ArgumentCaptor.forClass(SettingValue.class); brandingService.updateBrandingInformation(newBranding); verify(settingService, times(2)).set(settingContext.capture(), settingScope.capture(), settingKey.capture(), settingValue.capture()); List<Context> contexts = settingContext.getAllValues(); List<Scope> scopes = settingScope.getAllValues(); List<String> keys = settingKey.getAllValues(); List<SettingValue> values = settingValue.getAllValues(); assertEquals(Context.GLOBAL, contexts.get(0)); assertEquals(Scope.GLOBAL, scopes.get(0)); assertEquals(BrandingServiceImpl.BRANDING_COMPANY_NAME_SETTING_KEY, keys.get(0)); assertEquals("New Company Name", values.get(0).getValue()); assertEquals(Context.GLOBAL, contexts.get(1)); assertEquals(Scope.GLOBAL, scopes.get(1)); assertEquals(BrandingServiceImpl.BRANDING_TOPBAR_THEME_SETTING_KEY, keys.get(1)); assertEquals("Pink", values.get(1).getValue()); }
@Override public void updateBrandingInformation(Branding branding) throws Exception { updateCompanyName(branding.getCompanyName()); updateTopBarTheme(branding.getTopBarTheme()); updateLogo(branding.getLogo()); }
BrandingServiceImpl implements BrandingService { @Override public void updateBrandingInformation(Branding branding) throws Exception { updateCompanyName(branding.getCompanyName()); updateTopBarTheme(branding.getTopBarTheme()); updateLogo(branding.getLogo()); } }
BrandingServiceImpl implements BrandingService { @Override public void updateBrandingInformation(Branding branding) throws Exception { updateCompanyName(branding.getCompanyName()); updateTopBarTheme(branding.getTopBarTheme()); updateLogo(branding.getLogo()); } BrandingServiceImpl(InitParams initParams,SettingService settingService, FileService fileService, UploadService uploadService); }
BrandingServiceImpl implements BrandingService { @Override public void updateBrandingInformation(Branding branding) throws Exception { updateCompanyName(branding.getCompanyName()); updateTopBarTheme(branding.getTopBarTheme()); updateLogo(branding.getLogo()); } BrandingServiceImpl(InitParams initParams,SettingService settingService, FileService fileService, UploadService uploadService); @Override Branding getBrandingInformation(); @Override void updateBrandingInformation(Branding branding); @Override String getCompanyName(); @Override void updateCompanyName(String companyName); @Override String getTopBarTheme(); @Override Long getLogoId(); @Override Logo getLogo(); @Override Logo getDefaultLogo(); @Override void updateTopBarTheme(String topBarTheme); @Override void updateLogo(Logo logo); }
BrandingServiceImpl implements BrandingService { @Override public void updateBrandingInformation(Branding branding) throws Exception { updateCompanyName(branding.getCompanyName()); updateTopBarTheme(branding.getTopBarTheme()); updateLogo(branding.getLogo()); } BrandingServiceImpl(InitParams initParams,SettingService settingService, FileService fileService, UploadService uploadService); @Override Branding getBrandingInformation(); @Override void updateBrandingInformation(Branding branding); @Override String getCompanyName(); @Override void updateCompanyName(String companyName); @Override String getTopBarTheme(); @Override Long getLogoId(); @Override Logo getLogo(); @Override Logo getDefaultLogo(); @Override void updateTopBarTheme(String topBarTheme); @Override void updateLogo(Logo logo); static final String BRANDING_COMPANY_NAME_INIT_PARAM; static final String BRANDING_LOGO_INIT_PARAM; static final String BRANDING_COMPANY_NAME_SETTING_KEY; static final String BRANDING_TOPBAR_THEME_SETTING_KEY; static final String BRANDING_LOGO_ID_SETTING_KEY; static final String FILE_API_NAME_SPACE; static final String BRANDING_DEFAULT_LOGO_PATH; static String LOGO_NAME; }