package uk.ac.ebi.quickgo.rest.service;

import uk.ac.ebi.quickgo.rest.search.QueryStringSanitizer;

import java.util.Collections;
import java.util.List;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.mockito.Mockito.when;

/**
 * @author Tony Wardell
 * Date: 01/04/2016
 * Time: 13:31
 * Created with IntelliJ IDEA.
 */
@RunWith(MockitoJUnitRunner.class)
public class ServiceHelperImplTest {

	@Rule
	public ExpectedException thrown= ExpectedException.none();

	private ServiceHelper serviceHelper;

	@Mock
	private QueryStringSanitizer queryStringSanitizer;

	public static final String SINGLE_ID = "A0A000";
	public static final String[] SINGLE_ID_LIST = new String[]{"A0A000"};


	@Before
	public void setup(){
		serviceHelper = new ServiceHelperImpl(queryStringSanitizer);
		when(queryStringSanitizer.sanitize(SINGLE_ID)).thenReturn(SINGLE_ID);
	}


	@Test
	public void valid(){
		List<String> sanitizedList = serviceHelper.buildIdList(Collections.singletonList(SINGLE_ID));
		assertThat(sanitizedList, containsInAnyOrder(SINGLE_ID));

	}

	@Test
	public void blowupIfNull(){
		thrown.expect(IllegalArgumentException.class);
		List<String>  sanitizedList = serviceHelper.buildIdList(null);
	}
}

@@ -690,17 +690,22 @@
 t %7B%0A
-%0A%09
+    
 @Rule%0A
-%09
+    
 publ
@@ -731,16 +731,17 @@
 n thrown
+ 
 = Expect
@@ -765,55 +765,22 @@
 );%0A%0A
-%09private ServiceHelper serviceHelper;%0A%0A%09
+    
 @Mock%0A
-%09
+    
 priv
@@ -831,65 +831,61 @@
 r;%0A%0A
-%09public static final String SINGLE_ID = %22A0A000%22;%0A%09public
+    private ServiceHelper serviceHelper;%0A%0A    private
  sta
@@ -900,18 +900,16 @@
 l String
-%5B%5D
  SINGLE_
@@ -914,37 +914,19 @@
 E_ID
-_LIST = new String%5B%5D%7B
+ = 
 %22A0A000%22
 %7D;%0A%0A
@@ -925,22 +925,23 @@
 000%22
-%7D
 ;%0A%0A
-%0A%09
+    
 @Before%0A
 %09pub
@@ -936,17 +936,20 @@
 @Before%0A
-%09
+    
 public v
@@ -959,20 +959,27 @@
  setup()
+ 
 %7B%0A
-%09%09
+        
 serviceH
@@ -1031,18 +1031,24 @@
 tizer);%0A
-%09%09
+        
 when(que
@@ -1113,21 +1113,29 @@
 D);%0A
-%09%7D%0A%0A%0A%09
+    %7D%0A%0A    
 @Test%0A
-%09
+    
 publ
@@ -1149,20 +1149,27 @@
  valid()
+ 
 %7B%0A
-%09%09
+        
 List%3CStr
@@ -1254,18 +1254,24 @@
 E_ID));%0A
-%09%09
+        
 assertTh
@@ -1324,21 +1324,29 @@
 ));%0A
-%0A%09%7D%0A%0A%09
+    %7D%0A%0A    
 @Test%0A
-%09
+    
 publ
@@ -1371,12 +1371,19 @@
 ll()
+ 
 %7B%0A
-%09%09
+        
 thro
@@ -1429,39 +1429,15 @@
 s);%0A
-%09%09List%3CString%3E  sanitizedList =
+       
  ser
@@ -1470,9 +1470,11 @@
 l);%0A
-%09
+    
 %7D%0A%7D
-%0A

Make static fields private, and remove unused attributes.