package analyzer;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

import org.hamcrest.CoreMatchers;
import org.junit.Test;

public class ArrayJoinTest {
	
	private static final String[] array = new String[] {"a", "b", "c"};
	private static final Toiner t = new Toiner();
	private static Toiner t2;

	@Test
	public void test_simple_join() throws Exception {
		Joiner j = new Joiner();
	
		assertThat(j.join(array), equalTo("abc"));
	}
	
	@Test
	public void test_join_with_comma() throws Exception {
		Joiner j = new Joiner(",");
		assertThat(j.join(array), equalTo("a,b,c"));
	}
	
	@Test
	public void not_interesting() throws Exception {
		Joiner[] js = new Joiner[1];
		new Toiner();
		Toiner tt = new Toiner();
		t2 = new Toiner();
		assertTrue(tt.getValue());
		assertFalse(tt.getUID().equals(t2.getUID()));
	}
	
	@Test
	public void identity_test() throws Exception {
		Joiner a = new Joiner();
		Joiner b = a;
		assertTrue(a == b);
		assertFalse(a != b);
	}
	
	@Test
	public void in_assert_creation() throws Exception {
		assertEquals("abc", new Joiner().join(array));
		assertThat(new Joiner(), notNullValue());
	}
}

@@ -349,16 +349,63 @@
 .Test;%0A%0A
+// rank Joiner 1: because of string similarity%0A
 public c
@@ -495,16 +495,52 @@
 %22, %22c%22%7D;
+%0A%0A%09// rank Toiner 1: object creation
 %0A%09privat
@@ -669,36 +669,126 @@
 n %7B%0A
-%09%09Joiner j = new Joiner();%0A%09
+        // rank Joiner 2: object creation%0A%09%09Joiner j = new Joiner();%0A%0A        // rank Joiner 3: method call in assert*
 %0A%09%09a
@@ -824,33 +824,32 @@
 lTo(%22abc%22));%0A%09%7D%0A
-%09
 %0A%09@Test%0A%09public 
@@ -899,37 +899,129 @@
 n %7B%0A
-%09%09Joiner j = new Joiner(%22,%22);
+        // rank Joiner 4: object creatiopn%0A%09%09Joiner j = new Joiner(%22,%22);%0A        // rank Joiner 5: method call in assert*
 %0A%09%09a
@@ -1063,25 +1063,24 @@
 ,b,c%22));%0A%09%7D%0A
-%09
 %0A%09@Test%0A%09pub
@@ -1160,101 +1160,387 @@
 1%5D;%0A
-%09%09new Toiner();%0A%09%09Toiner tt = new Toiner();%0A%09%09t2 = new Toiner();%0A%09%09assertTrue(tt.getValue());
+        // doesn't get ranked because object not assigned to variable%0A%09%09new Toiner();%0A        // rank Toiner 2: object creation%0A%09%09Toiner tt = new Toiner();%0A        // rank Toiner 3: assignment%0A%09%09t2 = new Toiner();%0A        // rank Toiner 4: method call in assert*%0A%09%09assertTrue(tt.getValue());%0A        // rank Toiner 5: method call on tt%0A        // rank Toiner 6: method call on t2
 %0A%09%09a
@@ -1583,25 +1583,24 @@
 UID()));%0A%09%7D%0A
-%09
 %0A%09@Test%0A%09pub
@@ -1635,32 +1635,74 @@
 ows Exception %7B%0A
+        // rank Joiner 6: object creation%0A
 %09%09Joiner a = new
@@ -1732,29 +1732,117 @@
  a;%0A
-%09%09assertTrue(a == b);
+        // rank Joiner 8: usage in assert*%0A%09%09assertTrue(a == b);%0A        // rank Joiner 10: ussage in assert*
 %0A%09%09a
@@ -1864,17 +1864,16 @@
  b);%0A%09%7D%0A
-%09
 %0A%09@Test%0A
@@ -1929,56 +1929,254 @@
 n %7B%0A
-%09%09assertEquals(%22abc%22, new Joiner().join(array));
+        // rank Joiner 11: object creation in  assert*%0A        // we don't rank the object creation individually because this is one off.%0A        assertEquals(%22abc%22, new Joiner().join(array));%0A        // rank Joiner 12: object creation in assert*
 %0A%09%09a

Annotate test with ranking scheme.