class ZTSClient implements Closeable {

    public HostServices getHostServices(String host) {
        updateServicePrincipal();
        try {
            return ztsClient.getHostServices(host);
        } catch (ResourceException ex) {
            throw new ZTSClientException(ex.getCode(), ex.getData());
        } catch (Exception ex) {
            throw new ZTSClientException(ZTSClientException.BAD_REQUEST, ex.getMessage());
        }
    }

}

class ZTSClientTest {

    final private Authority PRINCIPAL_AUTHORITY;
    private SimpleServiceIdentityProvider siaMockProvider;
    private final static String crlf;
    private final static String test_cert;

    @Test
    public void testGetHostServices() {


        Principal principal = SimplePrincipal.create("user_domain", "user",
                "auth_creds", PRINCIPAL_AUTHORITY);

        ZTSRDLClientMock ztsClientMock = new ZTSRDLClientMock();
        ZTSClient client = new ZTSClient("http://localhost:4080", principal);
        ZTSClient.cancelPrefetch();
        client.setZTSRDLGeneratedClient(ztsClientMock);

        HostServices hostServices = client.getHostServices("host.exist");

        assertEquals(hostServices.getHost(), "host.exist");
        assertEquals(hostServices.getNames().size(), 2);

        try {
            client.getHostServices("not.exist.host");
            fail();
        } catch (ZTSClientException ex) {
            assertEquals(ex.getCode(), 404);
        }

        client.close();
    }

}