@Test
public void testValidateMaxLoadBalancers() throws Exception {

    when(jobOperations.getJob(JOB_ID)).thenReturn(Optional.of(Job.<ServiceJobExt>newBuilder()
            .withId(JOB_ID)
            .withStatus(JobStatus.newBuilder()
                    .withState(JobState.Accepted)
                    .build())
            .withJobDescriptor(JobDescriptor.<ServiceJobExt>newBuilder()
                    .withExtensions(ServiceJobExt.newBuilder().build())
                    .withContainer(Container.newBuilder()
                            .withImage(Image.newBuilder().build())
                            .withContainerResources(ContainerResources.newBuilder()
                                    .withAllocateIP(true)
                                    .build())
                            .build())
                    .build())
            .build()));
    when(loadBalancerValidationConfiguration.getMaxLoadBalancersPerJob()).thenReturn(30);
    for (int i = 0; i < loadBalancerValidationConfiguration.getMaxLoadBalancersPerJob() + 1; i++) {
        loadBalancerStore.addOrUpdateLoadBalancer(new JobLoadBalancer(JOB_ID, "LoadBalancer-" + i), JobLoadBalancer.State.ASSOCIATED).await(TIMEOUT_MS, TimeUnit.MILLISECONDS);
    }
    Throwable thrown = catchThrowable(() -> loadBalancerValidator.validateJobId(JOB_ID));
    assertThat(thrown).isInstanceOf(LoadBalancerException.class);
    assertThat(((LoadBalancerException) thrown).getErrorCode()).isEqualTo(LoadBalancerException.ErrorCode.JobMaxLoadBalancers);
}