@Test(expected = IllegalArgumentException.class) public void testFindOriginalGatewayNotAllSameId() { TransitGateway tgw1 = mock(TransitGateway.class); when(tgw1.getId()).thenReturn("id1"); TransitGateway tgw2 = mock(TransitGateway.class); when(tgw2.getId()).thenReturn("id2"); TransitGatewayWithMetadata t1 = new TransitGatewayWithMetadata(tgw1, new Region("r1"), "account1"); TransitGatewayWithMetadata t2 = new TransitGatewayWithMetadata(tgw2, new Region("r1"), "account1"); TransitGatewayConverter.findOriginalGateway(ImmutableList.of(t1, t2)); }
@VisibleForTesting @Nullable static TransitGatewayWithMetadata findOriginalGateway( Collection<TransitGatewayWithMetadata> tgws) { checkArgument(!tgws.isEmpty()); checkArgument( tgws.stream().map(TransitGatewayWithMetadata::getTransitGatewayId).distinct().count() == 1); if (tgws.size() == 1) { return tgws.iterator().next(); } return tgws.stream().filter(TransitGatewayWithMetadata::isOriginal).findFirst().orElse(null); }
TransitGatewayConverter { @VisibleForTesting @Nullable static TransitGatewayWithMetadata findOriginalGateway( Collection<TransitGatewayWithMetadata> tgws) { checkArgument(!tgws.isEmpty()); checkArgument( tgws.stream().map(TransitGatewayWithMetadata::getTransitGatewayId).distinct().count() == 1); if (tgws.size() == 1) { return tgws.iterator().next(); } return tgws.stream().filter(TransitGatewayWithMetadata::isOriginal).findFirst().orElse(null); } }
TransitGatewayConverter { @VisibleForTesting @Nullable static TransitGatewayWithMetadata findOriginalGateway( Collection<TransitGatewayWithMetadata> tgws) { checkArgument(!tgws.isEmpty()); checkArgument( tgws.stream().map(TransitGatewayWithMetadata::getTransitGatewayId).distinct().count() == 1); if (tgws.size() == 1) { return tgws.iterator().next(); } return tgws.stream().filter(TransitGatewayWithMetadata::isOriginal).findFirst().orElse(null); } private  TransitGatewayConverter(); }
TransitGatewayConverter { @VisibleForTesting @Nullable static TransitGatewayWithMetadata findOriginalGateway( Collection<TransitGatewayWithMetadata> tgws) { checkArgument(!tgws.isEmpty()); checkArgument( tgws.stream().map(TransitGatewayWithMetadata::getTransitGatewayId).distinct().count() == 1); if (tgws.size() == 1) { return tgws.iterator().next(); } return tgws.stream().filter(TransitGatewayWithMetadata::isOriginal).findFirst().orElse(null); } private  TransitGatewayConverter(); static List<Configuration> convertTransitGateways(
      AwsConfiguration awsConfiguration, ConvertedConfiguration configs); }
TransitGatewayConverter { @VisibleForTesting @Nullable static TransitGatewayWithMetadata findOriginalGateway( Collection<TransitGatewayWithMetadata> tgws) { checkArgument(!tgws.isEmpty()); checkArgument( tgws.stream().map(TransitGatewayWithMetadata::getTransitGatewayId).distinct().count() == 1); if (tgws.size() == 1) { return tgws.iterator().next(); } return tgws.stream().filter(TransitGatewayWithMetadata::isOriginal).findFirst().orElse(null); } private  TransitGatewayConverter(); static List<Configuration> convertTransitGateways(
      AwsConfiguration awsConfiguration, ConvertedConfiguration configs);  }