SecurityFactory { @Provides public RestxSessionCookieDescriptor restxSessionCookieDescriptor(@Named("app.name") Optional<String> appName){ if(appName.isPresent()){ return new RestxSessionCookieDescriptor( String.format("%s-%s", "RestxSession", appName.get()), String.format("%s-%s", "RestxSessionSignature", appName.get())); } else { return new RestxSessionCookieDescriptor("RestxSession", "RestxSessionSignature"); } }  @Provides RestxSessionCookieDescriptor restxSessionCookieDescriptor(@Named("app.name") Optional<String> appName);  }
@Test public void should_app_named_dependent_cookie_be_correctly_generated(){ RestxSessionCookieDescriptor cookieDescriptor = new SecurityFactory().restxSessionCookieDescriptor(Optional.fromNullable(this.appName)); assertThat(cookieDescriptor.getCookieName(), is(equalTo(this.expectedCookieName))); assertThat(cookieDescriptor.getCookieSignatureName(), is(equalTo(this.expectedCookieSignatureName))); }