@@ -0,0 +1,2116 @@
+package de.retest.recheck.ui.diff;%0A%0Aimport static de.retest.recheck.ui.diff.ElementBuilder.toAttributes;%0Aimport static org.mockito.Mockito.mock;%0A%0Aimport java.util.TreeSet;%0A%0Aimport org.assertj.core.api.Assertions;%0Aimport org.junit.Test;%0A%0Aimport de.retest.recheck.ui.Path;%0Aimport de.retest.recheck.ui.PathElement;%0Aimport de.retest.recheck.ui.descriptors.Attributes;%0Aimport de.retest.recheck.ui.descriptors.Element;%0Aimport de.retest.recheck.ui.descriptors.IdentifyingAttributes;%0Aimport de.retest.recheck.ui.descriptors.MutableAttributes;%0A%0Apublic class MatchTest %7B%0A%0A%09public static final double ONE_SIMILARITY = 1.0d / IdentifyingAttributes.PERFECT_SIMILARITY;%0A%0A%09@Test%0A%09public void test_better_comp_always_comes_out_first() %7B%0A%09%09final Element comp1 = getElement( comp1.class, 1 );%0A%09%09final Match match1 = new Match( 0.9d + ONE_SIMILARITY, comp1 );%0A%0A%09%09final Element comp2 = getElement( comp2.class, 2 );%0A%09%09final Match match2 = new Match( 0.9d, comp2 );%0A%0A%09%09final TreeSet%3CMatch%3E bestMatches = new TreeSet%3C%3E();%0A%09%09bestMatches.add( match1 );%0A%09%09bestMatches.add( match2 );%0A%0A%09%09Assertions.assertThat( bestMatches.pollFirst().element ).isSameAs( comp1 );%0A%09%09Assertions.assertThat( bestMatches.pollFirst().element ).isSameAs( comp2 );%0A%09%7D%0A%0A%09@Test%0A%09public void same_score_doesnt_overwrite() %7B%0A%09%09final Element comp1 = getElement( comp2.class, 2 );%0A%09%09final Match match1 = new Match( 0.9d, comp1 );%0A%0A%09%09final Element comp2 = getElement( comp2.class, 2 );%0A%09%09final Match match2 = new Match( 0.9d, comp2 );%0A%0A%09%09final TreeSet%3CMatch%3E bestMatches = new TreeSet%3C%3E();%0A%09%09bestMatches.add( match1 );%0A%09%09bestMatches.add( match2 );%0A%0A%09%09Assertions.assertThat( bestMatches.size() ).isEqualTo( 2 );%0A%09%7D%0A%0A%09private Element getElement( final Class%3C?%3E clazz, final int cnt ) %7B%0A%09%09return Element.create( %22id%22, mock( Element.class ),%0A%09%09%09%09IdentifyingAttributes.create( Path.path( new PathElement( clazz.getSimpleName(), 1 ) ), clazz ),%0A%09%09%09%09toAttributes( %22%7Bcolor=green%7D%22 ) );%0A%09%7D%0A%0A%09private class comp1 extends Element %7B%0A%09%09private static final long serialVersionUID = 1L;%0A%09%7D;%0A%0A%09private class comp2 extends Element %7B%0A%09%09private static final long serialVersionUID = 1L;%0A%09%7D;%0A%7D%0A

Move tests for Match from review