A PR arrived in the customer alias merging service with a simplification of the model and merge logic. After the change, problems appeared in scenarios with repeated customers and when working with sets. You need to review the code and find defects in the changed code.
CustomerAlias records and returns the final list after merging by the business customer identifier.customerId, only one record should remain in the result.customerId;alias value from the input list;tags without duplicates and preserving the order of first appearance.distinctCustomers method must remove duplicate customers by customerId, even if alias differs.merge result must match the order of first appearance of each customerId in the input list.javac src/*.java && java -cp src Main
Pay attention to two sets of symptoms:
merge result, more than one record may remain for a single customer;distinctCustomers result, customers with the same customerId are not removed if their alias differs.Also check the following merge scenario:
customerId, where the first record has the tag vip, the second has trial, and the second record has a non-empty alias;alias.merge returns no more than one record per customerId.alias is updated according to the last non-empty value rule.distinctCustomers considers customers equal by customerId, not by displayed fields.alias values or the same tags composition.javac src/*.java && java -cp src Mainsrc directorycustomerId is always non-empty; alias may be an empty string; tags are passed as a mutable List<String>Use line comments to explain the problem, its impact, the fix and how to test it.