Search in sources :

Example 1 with DescribeEnvironmentResourcesResult

use of com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentResourcesResult in project Synapse-Stack-Builder by Sage-Bionetworks.

the class ElbAlarmSetupTest method testGetLoadBalancerFromEnvironmentNameOneLoadBalancer.

@Test
public void testGetLoadBalancerFromEnvironmentNameOneLoadBalancer() throws Exception {
    // Return 1 load balancers
    List<LoadBalancer> loadBalancers = new ArrayList<>();
    LoadBalancer lb = new LoadBalancer().withName("loadBalancer");
    loadBalancers.add(lb);
    EnvironmentResourceDescription erd = new EnvironmentResourceDescription().withLoadBalancers(loadBalancers);
    DescribeEnvironmentResourcesResult expectedRes = new DescribeEnvironmentResourcesResult().withEnvironmentResources(erd);
    when(beanstalkClient.describeEnvironmentResources(any(DescribeEnvironmentResourcesRequest.class))).thenReturn(expectedRes);
    doNothing().when(mockSleeper).sleep(anyLong());
    LoadBalancer b = setup.getLoadBalancerFromEnvironmentName("repoEnvName");
    // Should have same name
    assertEquals(lb.getName(), b.getName());
}
Also used : DescribeEnvironmentResourcesResult(com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentResourcesResult) DescribeEnvironmentResourcesRequest(com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentResourcesRequest) ArrayList(java.util.ArrayList) LoadBalancer(com.amazonaws.services.elasticbeanstalk.model.LoadBalancer) EnvironmentResourceDescription(com.amazonaws.services.elasticbeanstalk.model.EnvironmentResourceDescription) Test(org.junit.Test)

Example 2 with DescribeEnvironmentResourcesResult

use of com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentResourcesResult in project Synapse-Stack-Builder by Sage-Bionetworks.

the class ElbAlarmSetupTest method testCreateAlarms.

@Test
public void testCreateAlarms() throws Exception {
    EnvironmentResourceDescription erd = new EnvironmentResourceDescription().withLoadBalancers(new LoadBalancer().withName("loadBalancer"));
    DescribeEnvironmentResourcesResult expectedErr = new DescribeEnvironmentResourcesResult().withEnvironmentResources(erd);
    when(beanstalkClient.describeEnvironmentResources(any(DescribeEnvironmentResourcesRequest.class))).thenReturn(expectedErr);
    setup.createAlarms(resources.getEnvironment(StackEnvironmentType.REPO));
    verify(mockCwClient).putMetricAlarm(any(PutMetricAlarmRequest.class));
}
Also used : DescribeEnvironmentResourcesResult(com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentResourcesResult) PutMetricAlarmRequest(com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest) DescribeEnvironmentResourcesRequest(com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentResourcesRequest) LoadBalancer(com.amazonaws.services.elasticbeanstalk.model.LoadBalancer) EnvironmentResourceDescription(com.amazonaws.services.elasticbeanstalk.model.EnvironmentResourceDescription) Test(org.junit.Test)

Example 3 with DescribeEnvironmentResourcesResult

use of com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentResourcesResult in project Synapse-Stack-Builder by Sage-Bionetworks.

the class ElbAlarmSetupTest method testGetLoadBalancerFromEnvironmentNameTwoLoadBalancers.

@Test(expected = IllegalStateException.class)
public void testGetLoadBalancerFromEnvironmentNameTwoLoadBalancers() throws Exception {
    // Return 2 load balancers
    List<LoadBalancer> loadBalancers = new ArrayList<>();
    LoadBalancer lb = new LoadBalancer();
    loadBalancers.add(lb);
    loadBalancers.add(lb);
    EnvironmentResourceDescription erd = new EnvironmentResourceDescription().withLoadBalancers(loadBalancers);
    DescribeEnvironmentResourcesResult expectedRes = new DescribeEnvironmentResourcesResult().withEnvironmentResources(erd);
    when(beanstalkClient.describeEnvironmentResources(any(DescribeEnvironmentResourcesRequest.class))).thenReturn(expectedRes);
    doNothing().when(mockSleeper).sleep(anyLong());
    setup.getLoadBalancerFromEnvironmentName("repoEnvName");
}
Also used : DescribeEnvironmentResourcesResult(com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentResourcesResult) DescribeEnvironmentResourcesRequest(com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentResourcesRequest) ArrayList(java.util.ArrayList) LoadBalancer(com.amazonaws.services.elasticbeanstalk.model.LoadBalancer) EnvironmentResourceDescription(com.amazonaws.services.elasticbeanstalk.model.EnvironmentResourceDescription) Test(org.junit.Test)

Example 4 with DescribeEnvironmentResourcesResult

use of com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentResourcesResult in project Synapse-Stack-Builder by Sage-Bionetworks.

the class ElbAlarmSetupTest method testGetLoadBalancerFromEnvironmentNameNoLoadBalancer.

@Test(expected = IllegalStateException.class)
public void testGetLoadBalancerFromEnvironmentNameNoLoadBalancer() throws Exception {
    // Return empty list
    EnvironmentResourceDescription erd = new EnvironmentResourceDescription().withLoadBalancers(new ArrayList<LoadBalancer>());
    DescribeEnvironmentResourcesResult expectedRes = new DescribeEnvironmentResourcesResult().withEnvironmentResources(erd);
    when(beanstalkClient.describeEnvironmentResources(any(DescribeEnvironmentResourcesRequest.class))).thenReturn(expectedRes);
    doNothing().when(mockSleeper).sleep(anyLong());
    setup.getLoadBalancerFromEnvironmentName("repoEnvName");
}
Also used : DescribeEnvironmentResourcesResult(com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentResourcesResult) DescribeEnvironmentResourcesRequest(com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentResourcesRequest) LoadBalancer(com.amazonaws.services.elasticbeanstalk.model.LoadBalancer) EnvironmentResourceDescription(com.amazonaws.services.elasticbeanstalk.model.EnvironmentResourceDescription) Test(org.junit.Test)

Example 5 with DescribeEnvironmentResourcesResult

use of com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentResourcesResult in project Synapse-Stack-Builder by Sage-Bionetworks.

the class ElbAlarmSetupTest method testGetLoadBalancerFromEnvironmentNameNullLoadBalancers.

@Test(expected = IllegalStateException.class)
public void testGetLoadBalancerFromEnvironmentNameNullLoadBalancers() throws Exception {
    EnvironmentResourceDescription erd = new EnvironmentResourceDescription();
    DescribeEnvironmentResourcesResult expectedRes = new DescribeEnvironmentResourcesResult().withEnvironmentResources(erd);
    when(beanstalkClient.describeEnvironmentResources(any(DescribeEnvironmentResourcesRequest.class))).thenReturn(expectedRes);
    doNothing().when(mockSleeper).sleep(anyLong());
    setup.getLoadBalancerFromEnvironmentName("repoEnvName");
}
Also used : DescribeEnvironmentResourcesResult(com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentResourcesResult) DescribeEnvironmentResourcesRequest(com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentResourcesRequest) EnvironmentResourceDescription(com.amazonaws.services.elasticbeanstalk.model.EnvironmentResourceDescription) Test(org.junit.Test)

Aggregations

DescribeEnvironmentResourcesRequest (com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentResourcesRequest)6 DescribeEnvironmentResourcesResult (com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentResourcesResult)6 EnvironmentResourceDescription (com.amazonaws.services.elasticbeanstalk.model.EnvironmentResourceDescription)6 LoadBalancer (com.amazonaws.services.elasticbeanstalk.model.LoadBalancer)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)2 PutMetricAlarmRequest (com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest)1