package com.atlassian.bitbucket.mesh.grpc;

import com.atlassian.bitbucket.mesh.AbstractGrpcServiceTest;
import com.atlassian.bitbucket.mesh.health.rpc.v1.HealthCheckRequest;
import com.atlassian.bitbucket.mesh.health.rpc.v1.HealthCheckResponse;
import com.atlassian.bitbucket.mesh.health.rpc.v1.HealthCheckResponse.ServingStatus;
import com.atlassian.bitbucket.mesh.health.rpc.v1.HealthGrpc;
import org.junit.Test;

public class GrpcHealthServiceTest extends AbstractGrpcServiceTest {

    @Test
    public void testCheck() {
        HealthCheckResponse response = blockingStub().check(HealthCheckRequest.getDefaultInstance());

        assertNotNull(response);
        assertEquals(ServingStatus.SERVING, response.getStatus());
    }

    private HealthGrpc.HealthBlockingStub blockingStub() {
        return HealthGrpc.newBlockingStub(managedChannel);
    }
}