### Question:
AccountInfoRetriever { @AccountStatus int getStatus(@NonNull String accountId) throws OperationFailedException { try { getBalance(accountId); return AccountStatus.ACTIVATED; } catch (AccountNotFoundException e) { return AccountStatus.NOT_CREATED; } catch (AccountNotActivatedException e) { return AccountStatus.NOT_ACTIVATED; } } AccountInfoRetriever(Server server, KinAsset kinAsset);   }### Answer:
@Test public void getStatus_CreatedAndActivated_StatusActivated() throws Exception { mockWebServer.enqueue(TestUtils.generateSuccessMockResponse(this.getClass(), "balance_res_success.json")); int status = getStatus(ACCOUNT_ID_KIN_ISSUER, ACCOUNT_ID); assertThat(status, equalTo(AccountStatus.ACTIVATED)); }
@Test public void getStatus_NoKinTrust_StatusNotActivated() throws Exception { mockWebServer.enqueue(TestUtils.generateSuccessMockResponse(this.getClass(), "balance_res_no_kin_trust.json")); int status = getStatus(ACCOUNT_ID_KIN_ISSUER, ACCOUNT_ID); assertThat(status, equalTo(AccountStatus.NOT_ACTIVATED)); }
@Test public void getStatus_SameIssuerDifferentAsset_StatusNotActivated() throws Exception { mockWebServer.enqueue(TestUtils .generateSuccessMockResponse(this.getClass(), "balance_res_same_issuer_different_asset_code.json")); int status = getStatus(ACCOUNT_ID_KIN_ISSUER, ACCOUNT_ID); assertThat(status, equalTo(AccountStatus.NOT_ACTIVATED)); }
@Test public void getStatus_IOException_OperationFailedException() throws Exception { mockWebServer.enqueue(new MockResponse().setSocketPolicy(SocketPolicy.DISCONNECT_AT_START)); expectedEx.expect(OperationFailedException.class); expectedEx.expectCause(isA(IOException.class)); getStatus(ACCOUNT_ID_KIN_ISSUER, ACCOUNT_ID); }
@Test public void getStatus_NullResponse_OperationFailedException() throws Exception { TestUtils.enqueueEmptyResponse(mockWebServer); expectedEx.expect(OperationFailedException.class); expectedEx.expectMessage(ACCOUNT_ID); getStatus(ACCOUNT_ID_KIN_ISSUER, ACCOUNT_ID); }
@Test public void getStatus_AccountNotExists_StatusNotCreated() throws Exception { mockWebServer.enqueue(new MockResponse() .setResponseCode(404) ); int status = getStatus(ACCOUNT_ID_KIN_ISSUER, ACCOUNT_ID); assertThat(status, equalTo(AccountStatus.NOT_CREATED)); }
@Test public void getStatus_HttpResponseError_OperationFailedException() throws Exception { mockWebServer.enqueue(new MockResponse() .setResponseCode(500) ); expectedEx.expect(OperationFailedException.class); expectedEx.expectCause(Matchers.<Throwable>instanceOf(HttpResponseException.class)); getStatus(ACCOUNT_ID_KIN_ISSUER, ACCOUNT_ID); }
@SuppressWarnings("ConstantConditions") @Test public void getStatus_NullInput_IllegalArgumentException() throws Exception { mockWebServer.enqueue(new MockResponse() .setResponseCode(500) ); expectedEx.expect(IllegalArgumentException.class); KinAsset kinAsset = createKinAsset(ACCOUNT_ID_KIN_ISSUER); AccountInfoRetriever accountInfoRetriever = new AccountInfoRetriever(server, kinAsset); accountInfoRetriever.getStatus(null); }