@Test public void testSetMultipleTopologies() { GatewayV4Request source = new GatewayV4Request(); GatewayTopologyV4Request topology1 = new GatewayTopologyV4Request(); topology1.setTopologyName("topology1"); topology1.setExposedServices(Collections.singletonList("AMBARI")); GatewayTopologyV4Request topology2 = new GatewayTopologyV4Request(); topology2.setTopologyName("topology2"); topology2.setExposedServices(Collections.singletonList("ALL")); source.setTopologies(Arrays.asList(topology1, topology2)); Gateway result = new Gateway(); when(converterUtil.convert(any(), any())).thenReturn(new GatewayTopology()); underTest.setTopologies(source, result); verify(converterUtil, times(2)).convert(any(), any()); }
public void setTopologies(GatewayV4Request source, Gateway gateway) { if (!CollectionUtils.isEmpty(source.getTopologies())) { Set<GatewayTopology> gatewayTopologies = source.getTopologies().stream() .map(g -> converterUtil.convert(g, GatewayTopology.class)) .collect(Collectors.toSet()); gateway.setTopologies(gatewayTopologies); gatewayTopologies.forEach(g -> g.setGateway(gateway)); } }
GatewayConvertUtil { public void setTopologies(GatewayV4Request source, Gateway gateway) { if (!CollectionUtils.isEmpty(source.getTopologies())) { Set<GatewayTopology> gatewayTopologies = source.getTopologies().stream() .map(g -> converterUtil.convert(g, GatewayTopology.class)) .collect(Collectors.toSet()); gateway.setTopologies(gatewayTopologies); gatewayTopologies.forEach(g -> g.setGateway(gateway)); } } }
GatewayConvertUtil { public void setTopologies(GatewayV4Request source, Gateway gateway) { if (!CollectionUtils.isEmpty(source.getTopologies())) { Set<GatewayTopology> gatewayTopologies = source.getTopologies().stream() .map(g -> converterUtil.convert(g, GatewayTopology.class)) .collect(Collectors.toSet()); gateway.setTopologies(gatewayTopologies); gatewayTopologies.forEach(g -> g.setGateway(gateway)); } }  }
GatewayConvertUtil { public void setTopologies(GatewayV4Request source, Gateway gateway) { if (!CollectionUtils.isEmpty(source.getTopologies())) { Set<GatewayTopology> gatewayTopologies = source.getTopologies().stream() .map(g -> converterUtil.convert(g, GatewayTopology.class)) .collect(Collectors.toSet()); gateway.setTopologies(gatewayTopologies); gatewayTopologies.forEach(g -> g.setGateway(gateway)); } }  void setTopologies(GatewayV4Request source, Gateway gateway); void setGatewayPathAndSsoProvider(GatewayV4Request source, Gateway gateway); void setBasicProperties(GatewayV4Request source, Gateway gateway); void generateSignKeys(Gateway gateway); }
GatewayConvertUtil { public void setTopologies(GatewayV4Request source, Gateway gateway) { if (!CollectionUtils.isEmpty(source.getTopologies())) { Set<GatewayTopology> gatewayTopologies = source.getTopologies().stream() .map(g -> converterUtil.convert(g, GatewayTopology.class)) .collect(Collectors.toSet()); gateway.setTopologies(gatewayTopologies); gatewayTopologies.forEach(g -> g.setGateway(gateway)); } }  void setTopologies(GatewayV4Request source, Gateway gateway); void setGatewayPathAndSsoProvider(GatewayV4Request source, Gateway gateway); void setBasicProperties(GatewayV4Request source, Gateway gateway); void generateSignKeys(Gateway gateway);  }