package de.dhbw.humbuch.view;

import static de.dhbw.humbuch.test.TestUtils.randomUser;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;

import java.util.ArrayList;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import com.google.inject.Inject;
import com.vaadin.ui.Field;

import de.dhbw.humbuch.guice.GuiceJUnitRunner;
import de.dhbw.humbuch.guice.TestModule;
import de.dhbw.humbuch.guice.GuiceJUnitRunner.GuiceModules;
import de.dhbw.humbuch.model.DAO;
import de.dhbw.humbuch.model.entity.TestPersistenceInitialiser;
import de.dhbw.humbuch.model.entity.User;
import de.dhbw.humbuch.viewmodel.Properties;

@RunWith(GuiceJUnitRunner.class)
@GuiceModules({ TestModule.class })
public class SettingsViewTest {

	private SettingsView settingsView;
	private Properties properties;
	private DAO<User> daoUser;

	@Inject
	public void setInjected(MVVMConfig mvvmConfig,
			TestPersistenceInitialiser testPersistenceInitialiser,
			SettingsView settingsView,
			Properties properties,
			DAO<User> daoUser) {
		this.settingsView = settingsView;
		this.properties = properties;
		this.daoUser = daoUser;

	}
	
	@Before
	public void setLoggedInUser() {
		properties.currentUser.set(daoUser.insert(randomUser()));
	}

	@Test
	public void testInstantiation() {
		assertThat(settingsView, notNullValue());
	}
	
	@Test
	public void testEnter() {
		settingsView.enter(null);
	}
	
	@Test
	public void testTitleNotNull() {
		assertThat(settingsView.getTitle(), notNullValue());
	}
	
	@Test
	@SuppressWarnings("rawtypes")
	public void testCommitFields() {
		settingsView.commitFields(new ArrayList<Field>());
	}
	
	@Test
	@SuppressWarnings("rawtypes")
	public void testDiscardFields() {
		settingsView.discardFields(new ArrayList<Field>());
	}
}

@@ -35,189 +35,29 @@
 ort 
-static de.dhbw.humbuch.test.TestUtils.randomUser;%0Aimport static org.junit.Assert.*;%0Aimport static org.hamcrest.CoreMatchers.*;%0A%0Aimport java.util.ArrayList;%0A%0Aimport org.junit.Before;
+java.util.ArrayList;%0A
 %0Aimp
@@ -223,49 +223,8 @@
 er;%0A
-import de.dhbw.humbuch.guice.TestModule;%0A
 impo
@@ -279,16 +279,57 @@
 odules;%0A
+import de.dhbw.humbuch.guice.TestModule;%0A
 import d
@@ -605,16 +605,33 @@
 iewTest 
+extends BaseTest 
 %7B%0A%0A%09priv
@@ -664,68 +664,8 @@
 iew;
-%0A%09private Properties properties;%0A%09private DAO%3CUser%3E daoUser;
 %0A%0A%09@
@@ -793,25 +793,17 @@
 ngsView 
-settingsV
+v
 iew,%0A%09%09%09
@@ -875,443 +875,99 @@
 w = 
-settingsView;%0A%09%09this.properties = properties;%0A%09%09this.daoUser = daoUser;%0A%0A%09%7D%0A%09%0A%09@Before%0A%09public void setLoggedInUser() %7B%0A%09%09properties.currentUser.set(daoUser.insert(randomUser()));%0A%09%7D%0A%0A%09@Test%0A%09public void testInstantiation() %7B%0A%09%09assertThat(settingsView, notNullValue());%0A%09%7D%0A%09%0A%09@Test%0A%09public void testEnter() %7B%0A%09%09settingsView.enter(null);%0A%09%7D%0A%09%0A%09@Test%0A%09public void testTitleNotNull() %7B%0A%09%09assertThat(settingsView.getTitle(), notNullValue()
+view;%0A%09%09super.setInjected(mvvmConfig, testPersistenceInitialiser, view, properties, daoUser
 );%0A%09

use BaseTest