### Question:
CloudStoreRestClient { public synchronized String getBaseUrl() { if (baseURL == null) { determineBaseUrl(); } return baseURL; } CloudStoreRestClient(final URL url, final ClientBuilder clientBuilder);  CloudStoreRestClient(final String url, final ClientBuilder clientBuilder); synchronized String getBaseUrl(); R execute(final Request<R> request); Invocation.Builder assignCredentials(final Invocation.Builder builder); Client getClientOrFail(); CredentialsProvider getCredentialsProvider(); void setCredentialsProvider(final CredentialsProvider credentialsProvider);  }### Answer:
@Test(expected = IllegalStateException.class) public void baseUrlNotFound() throws MalformedURLException { new StrictExpectations() {{ clientBuilder.build(); result = client; client.register(any); result = client; client.target("https: result = new WebApplicationException(); }}; cloudstoreClient = new CloudStoreRestClient("https: cloudstoreClient.getBaseUrl(); }
@Test public void successAtTheFirstCall() { new StrictExpectations() {{ clientBuilder.build(); result = client; client.register(any); result = client; client.target("https: result = "SUCCESS"; }}; cloudstoreClient = new CloudStoreRestClient("https: String result = cloudstoreClient.getBaseUrl(); assertThat(result).isEqualTo("https: new Verifications() {{ client.target("https: client.target("https: }}; }
@Test public void urlIsBaseUrl() { new StrictExpectations() {{ clientBuilder.build(); result = client; client.register(any); result = client; client.target("https: result = "SUCCESS"; }}; cloudstoreClient = new CloudStoreRestClient("https: String result = cloudstoreClient.getBaseUrl(); assertThat(result).isEqualTo("https: }
@Test public void doubleSlashInUrl() { new StrictExpectations() {{ clientBuilder.build(); result = client; client.register(any); result = client; client.target("https: result = new WebApplicationException(); client.target("https: result = new WebApplicationException(); client.target("https: result = new WebApplicationException(); client.target("https: result = new WebApplicationException(); client.target("https: result = "SUCCESS"; }}; cloudstoreClient = new CloudStoreRestClient("https: String result = cloudstoreClient.getBaseUrl(); assertThat(result).isEqualTo("https: }
@Test public void successAtTheLastCall() { new StrictExpectations() {{ clientBuilder.build(); result = client; client.register(any); result = client; client.target("https: result = new WebApplicationException(); client.target("https: result = new WebApplicationException(); client.target("https: result = new WebApplicationException(); client.target("https: result = "SUCCESS"; }}; cloudstoreClient = new CloudStoreRestClient("https: String result = cloudstoreClient.getBaseUrl(); assertThat(result).isEqualTo("https: }
@Test public void successAtTheMiddleCall() { new StrictExpectations() {{ clientBuilder.build(); result = client; client.register(any); result = client; client.target("https: result = new WebApplicationException(); client.target("https: result = new WebApplicationException(); client.target("https: result = "SUCCESS"; }}; cloudstoreClient = new CloudStoreRestClient("https: String result = cloudstoreClient.getBaseUrl(); assertThat(result).isEqualTo("https: new Verifications() {{ client.target("https: }}; }
@Test public void urlWithoutPort() { new StrictExpectations() {{ clientBuilder.build(); result = client; client.register(any); result = client; client.target("https: result = new WebApplicationException(); client.target("https: result = "SUCCESS"; }}; cloudstoreClient = new CloudStoreRestClient("https: String result = cloudstoreClient.getBaseUrl(); assertThat(result).isEqualTo("https: new Verifications() {{ client.target("https: }}; }
@Test public void urlWithoutSlashAtTheEnd() { new StrictExpectations() {{ clientBuilder.build(); result = client; client.register(any); result = client; client.target("https: result = "SUCCESS"; }}; cloudstoreClient = new CloudStoreRestClient("https: String result = cloudstoreClient.getBaseUrl(); assertThat(result).isEqualTo("https: }