test_class.declarator: successResponse =
              "{\"stellar_address\":\"bob*stellar.org\",\"account_id\":\"GCW667JUHCOP5Y7KY6KGDHNPHFM4CS3FCBQ7QWDUALXTX3PGXLSOEALY\"}"
test_class.modifier: private final
test_class.original_string: private final String successResponse =
              "{\"stellar_address\":\"bob*stellar.org\",\"account_id\":\"GCW667JUHCOP5Y7KY6KGDHNPHFM4CS3FCBQ7QWDUALXTX3PGXLSOEALY\"}";
test_class.type: String
test_class.var_name: successResponse
test_class.declarator: successResponseWithMemo =
              "{\"stellar_address\":\"bob*stellar.org\",\"account_id\":\"GCW667JUHCOP5Y7KY6KGDHNPHFM4CS3FCBQ7QWDUALXTX3PGXLSOEALY\", \"memo_type\": \"text\", \"memo\": \"test\"}"
test_class.modifier: private final
test_class.original_string: private final String successResponseWithMemo =
              "{\"stellar_address\":\"bob*stellar.org\",\"account_id\":\"GCW667JUHCOP5Y7KY6KGDHNPHFM4CS3FCBQ7QWDUALXTX3PGXLSOEALY\", \"memo_type\": \"text\", \"memo\": \"test\"}";
test_class.type: String
test_class.var_name: successResponseWithMemo
test_class.declarator: notFoundResponse =
              "{\"code\":\"not_found\",\"message\":\"Account not found\"}"
test_class.modifier: private final
test_class.original_string: private final String notFoundResponse =
              "{\"code\":\"not_found\",\"message\":\"Account not found\"}";
test_class.type: String
test_class.var_name: notFoundResponse
test_class.declarator: stellarToml =
              "FEDERATION_SERVER = \"https://api.stellar.org/federation\""
test_class.modifier: private final
test_class.original_string: private final String stellarToml =
              "FEDERATION_SERVER = \"https://api.stellar.org/federation\"";
test_class.type: String
test_class.var_name: stellarToml
test_class.declarator: fakeClient
test_class.modifier: private
test_class.original_string: private OkHttpClient fakeClient;
test_class.type: OkHttpClient
test_class.var_name: fakeClient
test_class.declarator: mockWebServer
test_class.modifier: private
test_class.original_string: private MockWebServer mockWebServer;
test_class.type: MockWebServer
test_class.var_name: mockWebServer
test_class.declarator: server
test_class.modifier: private
test_class.original_string: private FederationServer server;
test_class.type: FederationServer
test_class.var_name: server
test_class.file: kin-sdk/kin-base/src/test/java/kin/base/federation/FederationServerTest.java
test_class.identifier: FederationServerTest
test_class.superclass: extends TestCase
test_case.body: @Test
      public void testCreateForDomain() throws IOException {
          OkHttpClient mockClient = mock(OkHttpClient.class);
          FederationServer.setHttpClient(mockClient);
          Call mockCall = mock(Call.class);
          when(mockClient.newCall((Request) any())).thenReturn(mockCall);
          Response mockResponseSuccess = new Response.Builder()
                  .code(200)
                  .message("OK")
                  .protocol(Protocol.HTTP_1_1)
                  .body(ResponseBody.create(MediaType.parse("application/json"), stellarToml))
                  .request(new Request.Builder()
                          .url("http://www.test.com")
                          .get()
                          .build())
                  .build();
  
          when(mockCall.execute()).thenReturn(mockResponseSuccess);
  
          FederationServer server = FederationServer.createForDomain("stellar.org");
          assertEquals(server.getServerUri().toString(), "https://api.stellar.org/federation");
          assertEquals(server.getDomain(), "stellar.org");
  
          ArgumentCaptor<Request> argument = ArgumentCaptor.forClass(Request.class);
          verify(mockClient).newCall(argument.capture());
  
          assertEquals(URI.create("https://stellar.org/.well-known/stellar.toml"), argument.getValue().url().uri());
      }
test_case.class_method_signature: FederationServerTest.testCreateForDomain()
test_case.full_signature: @Test public void testCreateForDomain()
test_case.identifier: testCreateForDomain
test_case.invocations: mock setHttpClient mock thenReturn when newCall any build request body protocol message code create parse build get url thenReturn when execute createForDomain assertEquals toString getServerUri assertEquals getDomain forClass newCall verify capture assertEquals create uri url getValue
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testCreateForDomain()
focal_class.declarator: serverUri
focal_class.modifier: private final
focal_class.original_string: private final URL serverUri;
focal_class.type: URL
focal_class.var_name: serverUri
focal_class.declarator: domain
focal_class.modifier: private final
focal_class.original_string: private final String domain;
focal_class.type: String
focal_class.var_name: domain
focal_class.declarator: httpClient = new OkHttpClient()
focal_class.modifier: private static
focal_class.original_string: private static OkHttpClient httpClient = new OkHttpClient();
focal_class.type: OkHttpClient
focal_class.var_name: httpClient
focal_class.file: kin-sdk/kin-base/src/main/java/kin/base/federation/FederationServer.java
focal_class.identifier: FederationServer
focal_class.class_method_signature: FederationServer.FederationServer(URL serverUri, String domain)
focal_class.full_signature: public  FederationServer(URL serverUri, String domain)
focal_class.identifier: FederationServer
focal_class.modifiers: public
focal_class.parameters: (URL serverUri, String domain)
focal_class.signature:  FederationServer(URL serverUri, String domain)
focal_class.class_method_signature: FederationServer.FederationServer(String serverUri, String domain)
focal_class.full_signature: public  FederationServer(String serverUri, String domain)
focal_class.identifier: FederationServer
focal_class.modifiers: public
focal_class.parameters: (String serverUri, String domain)
focal_class.signature:  FederationServer(String serverUri, String domain)
focal_class.class_method_signature: FederationServer.createForDomain(String domain)
focal_class.full_signature: public static FederationServer createForDomain(String domain)
focal_class.identifier: createForDomain
focal_class.modifiers: public static
focal_class.parameters: (String domain)
focal_class.return: FederationServer
focal_class.signature: FederationServer createForDomain(String domain)
focal_class.class_method_signature: FederationServer.resolveAddress(String address)
focal_class.full_signature: public FederationResponse resolveAddress(String address)
focal_class.identifier: resolveAddress
focal_class.modifiers: public
focal_class.parameters: (String address)
focal_class.return: FederationResponse
focal_class.signature: FederationResponse resolveAddress(String address)
focal_class.class_method_signature: FederationServer.getServerUri()
focal_class.full_signature: public URL getServerUri()
focal_class.identifier: getServerUri
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: URL
focal_class.signature: URL getServerUri()
focal_class.class_method_signature: FederationServer.getDomain()
focal_class.full_signature: public String getDomain()
focal_class.identifier: getDomain
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getDomain()
focal_class.class_method_signature: FederationServer.setHttpClient(OkHttpClient httpClient)
focal_class.full_signature: static void setHttpClient(OkHttpClient httpClient)
focal_class.identifier: setHttpClient
focal_class.modifiers: static
focal_class.parameters: (OkHttpClient httpClient)
focal_class.return: void
focal_class.signature: void setHttpClient(OkHttpClient httpClient)
focal_method.body: public static FederationServer createForDomain(String domain) {
          URI stellarTomlUri;
          try {
              StringBuilder uriBuilder = new StringBuilder();
              uriBuilder.append("https://");
              uriBuilder.append(domain);
              uriBuilder.append("/.well-known/stellar.toml");
              stellarTomlUri = new URI(uriBuilder.toString());
          } catch (URISyntaxException e) {
              throw new RuntimeException(e);
          }
          Toml stellarToml = null;
          try {
              Request request = new Request.Builder().get()
                      .url(stellarTomlUri.toString())
                      .build();
              Response response = httpClient.newCall(request)
                      .execute();
              if (response.code() >= 300) {
                  throw new StellarTomlNotFoundInvalidException();
              }
              ResponseBody body = response.body();
              if (body == null) {
                  throw new StellarTomlNotFoundInvalidException();
              }
              stellarToml = new Toml().read(body.string());
          } catch (IOException e) {
              throw new ConnectionErrorException();
          }
  
          String federationServer = stellarToml.getString("FEDERATION_SERVER");
          if (federationServer == null) {
              throw new NoFederationServerException();
          }
  
          return new FederationServer(federationServer, domain);
      }
focal_method.class_method_signature: FederationServer.createForDomain(String domain)
focal_method.full_signature: public static FederationServer createForDomain(String domain)
focal_method.identifier: createForDomain
focal_method.invocations: append append append toString build url get toString execute newCall code body read string getString
focal_method.modifiers: public static
focal_method.parameters: (String domain)
focal_method.return: FederationServer
focal_method.signature: FederationServer createForDomain(String domain)