public static Set<ServiceInstance> getServiceInstances(
            List<ClusterLoadAssignment> loadAssignments) {
        return loadAssignments.stream()
                .filter(Objects::nonNull)
                .flatMap(loadAssignment -> getServiceInstancesFromLoadAssignment(loadAssignment).stream())
                .collect(Collectors.toSet());
    }
@Test
    public void testGetServiceInstances() {
        List<ClusterLoadAssignment> assignments = Arrays.asList(
                null,
                createLoadAssignment("outbound|8080|subset1|serviceB.default.svc.cluster.local"),
                createLoadAssignment("outbound|8080|subset2|serviceB.default.svc.cluster.local"),
                createLoadAssignment("outbound|8080|serviceB.default.svc.cluster.local")
        );

        Set<ServiceInstance> result = XdsProtocolTransformer.getServiceInstances(assignments);
        Assert.assertEquals(2, result.size());
        Iterator<ServiceInstance> iterator = result.iterator();
        while (iterator.hasNext()) {
            ServiceInstance next = iterator.next();
            Assert.assertEquals("serviceB", next.getServiceName());
        }
    }