### Question:
PacmanEc2Utils { public static List<FlowLog> getFlowLogs(AmazonEC2 ec2ServiceClient, DescribeFlowLogsRequest describeFlowLogsRequest) { List<FlowLog> flowLogs = new ArrayList<>(); DescribeFlowLogsResult flowLogsResult; String nextToken = null; do { try { flowLogsResult = ec2ServiceClient .describeFlowLogs(describeFlowLogsRequest); } catch (RuleExecutionFailedExeption exception) { logger.error(exception.getMessage()); nextToken = null; continue; } if(null!=flowLogsResult){ flowLogs.addAll(flowLogsResult.getFlowLogs()); nextToken = flowLogsResult.getNextToken(); } describeFlowLogsRequest.setNextToken(nextToken); } while (null != nextToken); return flowLogs; } private  PacmanEc2Utils(); static List<Volume> collectAllVolumes(AmazonEC2 ec2ServiceClient,
            DescribeVolumesRequest request); static List<FlowLog> getFlowLogs(AmazonEC2 ec2ServiceClient,
            DescribeFlowLogsRequest describeFlowLogsRequest); static Filter setFilters(String filterName, String filterValue); static Map<String, Boolean> checkAccessibleToAll(
            Set<GroupIdentifier> secuityGroups, String portToCheck,
            String sgRulesUrl, String cidrIp);  }### Answer:
@SuppressWarnings("static-access") @Test public void getFlowLogsTest() throws Exception { FlowLog flowLog = new FlowLog(); flowLog.setFlowLogId("123"); Collection<FlowLog> flowLogs = new ArrayList<>(); flowLogs.add(flowLog); DescribeFlowLogsResult flowLogsResult = new DescribeFlowLogsResult(); flowLogsResult.setFlowLogs(flowLogs); when(ec2ServiceClient.describeFlowLogs(anyObject())).thenReturn(flowLogsResult); assertThat(pacmanEc2Utils.getFlowLogs(ec2ServiceClient,describeFlowLogsRequest),is(notNullValue())); when(ec2ServiceClient.describeFlowLogs(anyObject())).thenThrow(new RuleExecutionFailedExeption()); assertThat(pacmanEc2Utils.getFlowLogs(ec2ServiceClient,describeFlowLogsRequest),is(notNullValue())); }