/**
 * Copyright (C) 2009-2013 Simonsoft Nordic AB
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package se.simonsoft.cms.indexing.abx;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.util.Set;

import org.junit.Test;

import se.repos.indexing.IndexingDoc;
import se.repos.indexing.item.IndexingItemProgress;
import se.repos.indexing.twophases.IndexingDocIncrementalSolrj;

public class HandlerTitleSelectionTest {

	@Test
	public void thereShoudlBeFiveFieldKeys() {
		HandlerTitleSelection handler = new HandlerTitleSelection();
		Set<String> fieldNames = handler.getFieldKeys();
		assertEquals("Should contain 6 fields", 6, fieldNames.size());
		assertEquals("prop_cms.title", fieldNames.iterator().next().toString());
	}
	
	
	@Test
	public void shouldIndexKeyValueWithHighestPrio() {
		IndexingItemProgress progress = mock(IndexingItemProgress.class);
		IndexingDoc doc = new IndexingDocIncrementalSolrj();
		doc.setField("xmp_dc.title", "xmp dc title");
		doc.setField("embd_title", "embd title");
		doc.setField("xmp_dc.subject", "xmp dc subject");
		
		when(progress.getFields()).thenReturn(doc);
		
		HandlerTitleSelection handler = new HandlerTitleSelection();
		handler.handle(progress);
		
		assertEquals("embd title", doc.getFieldValue("title"));
		
	}
	
}

@@ -780,31 +780,8 @@
 n;%0A%0A
-import java.util.Set;%0A%0A
 impo
@@ -999,317 +999,8 @@
 st %7B
-%0A%0A%09@Test%0A%09public void thereShoudlBeFiveFieldKeys() %7B%0A%09%09HandlerTitleSelection handler = new HandlerTitleSelection();%0A%09%09Set%3CString%3E fieldNames = handler.getFieldKeys();%0A%09%09assertEquals(%22Should contain 6 fields%22, 6, fieldNames.size());%0A%09%09assertEquals(%22prop_cms.title%22, fieldNames.iterator().next().toString());%0A%09%7D
 %0A%09%0A%09

Remove public methods and too simple test.