JanbaneryFactory { public JanbaneryToWorkspace connectUsing(Configuration configuration) { RestClient restClient = getRestClient(configuration); return new JanbaneryToWorkspace(new Janbanery(configuration, restClient)); } JanbaneryFactory();  JanbaneryFactory(AsyncHttpClient asyncHttpClient);  JanbaneryFactory(RestClient restClient); JanbaneryToWorkspace connectUsing(Configuration configuration); JanbaneryToWorkspace connectUsing(String apiKey); JanbaneryToWorkspace connectUsing(String user, String password); Janbanery connectAndKeepUsing(String user, String password); void setAsyncHttpClient(AsyncHttpClient asyncHttpClient); void setEncodedBodyGenerator(ReflectionBodyGenerator encodedBodyGenerator); void setGson(Gson gson);  }
@Test public void shouldLoginUsingValidApiKey() throws Exception { configuration = new PropertiesConfiguration(VALID_CONF_FILE_LOCATION); janbanery = janbaneryFactory.connectUsing(configuration).toWorkspace(EXISTING_WORKSPACE); AuthProvider usedAuthProvider = janbanery.getAuthMode(); assertThat(usedAuthProvider).isInstanceOf(ApiKeyAuthProvider.class); }
@Test public void shouldLoginUsingPlainApiKey() throws Exception { Properties props = new Properties(); props.load(new FileInputStream(VALID_CONF_FILE_LOCATION)); String apiKey = props.getProperty(PropertiesConfiguration.P_APIKEY); janbanery = janbaneryFactory.connectUsing(apiKey).toWorkspace(EXISTING_WORKSPACE); AuthProvider usedAuthProvider = janbanery.getAuthMode(); assertThat(usedAuthProvider).isInstanceOf(ApiKeyAuthProvider.class); }
@Test public void shouldLoginWithUserPassButThenFallbackToApiKeyMode() throws Exception { Properties properties = new Properties(); properties.load(new FileInputStream(VALID_CONF_FILE_LOCATION)); String user = (String) properties.get("username"); String password = (String) properties.get("password"); janbanery = janbaneryFactory.connectUsing(user, password).toWorkspace(EXISTING_WORKSPACE); AuthProvider usedAuthProvider = janbanery.getAuthMode(); assertThat(usedAuthProvider).isInstanceOf(ApiKeyAuthProvider.class); }