public static String[] mergeTraits(String[]... traitsBySource) {
        if (traitsBySource == null || traitsBySource.length == 0) {
            return new String[0];
        }
        Set<String> existingKeys = new HashSet<>();
        List<String> mergedTraits = new ArrayList<>();
        for (String[] traits : traitsBySource) {
            if (traits != null && traits.length > 0) {
                for (String trait : traits) {
                    final String[] traitConfig = trait.split("=", 2);
                    if (!existingKeys.contains(traitConfig[0])) {
                        mergedTraits.add(trait);
                    }
                }
                existingKeys.clear();
                for (String trait : mergedTraits) {
                    final String[] traitConfig = trait.split("=", 2);
                    existingKeys.add(traitConfig[0]);
                }
            }
        }
        return mergedTraits.toArray(new String[0]);
    }
@Test
    public void mergeTraitsTest() {
        String[] defaultGroup = new String[] {
                "container.port=8080",
                "container.port-name=custom",
                "container.service-port-name=custom-port",
                "container.service-port=8443" };
        String[] overridesGroup = new String[] {
                "container.port=80",
                "container.service-port=443",
                "container.image-pull-policy=IfNotPresent" };
        String[] result = TraitHelper.mergeTraits(overridesGroup, defaultGroup);
        Assertions.assertNotNull(result);
        Assertions.assertEquals(5, result.length);
        Assertions.assertEquals("container.port=80", result[0]);
        Assertions.assertEquals("container.service-port-name=custom-port", result[4]);

        String[] resultEmptyDefault = TraitHelper.mergeTraits(overridesGroup, new String[0]);
        Assertions.assertNotNull(resultEmptyDefault);
        Assertions.assertEquals(3, resultEmptyDefault.length);
        Assertions.assertArrayEquals(overridesGroup, resultEmptyDefault);

        String[] resultNull = TraitHelper.mergeTraits(null);
        Assertions.assertNotNull(resultNull);
    }