package com.pollistics.models;

//import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;

import java.util.HashMap;

import static org.assertj.core.api.Assertions.assertThat;
//import static org.junit.Assert.fail;

public class PollTest {

	@Test
	public void membersTest() {
		HashMap<String, Integer> options = new HashMap<>();
		options.put("Blauw", 1);
		Poll p = new Poll("Kleuren", options);
		assertThat(p.getName().equals("Kleuren"));
		p.setName("andere naam");
		assertThat(p.getName().equals("andere naam"));
		assertThat(p.getOptions().keySet().contains("Blauw"));
		assertThat(p.getOptions().entrySet().contains(1));
		HashMap<String, Integer> newOptions = new HashMap<>();
		newOptions.put("Rood", 5);
		p.setOptions(newOptions);
		assertThat(p.getOptions().keySet().contains("Rood"));
		assertThat(p.getOptions().entrySet().contains(4));
		assertThat(p.getOptions().equals(newOptions));
	}

	@Test
	public void userTest() {
		HashMap<String, Integer> options = new HashMap<>();
		options.put("Blauw", 1);
		User user = new User("someone", "somepass");
		Poll p = new Poll("Kleuren", options, user);
		assertThat(p.getUser().equals(user));
		User newUser = new User("other person", "pass");
		p.setUser(newUser);
		assertThat(p.getUser().equals(newUser));
	}

	@Test
	public void voteTest() {
		HashMap<String, Integer> options = new HashMap<>();
		options.put("Blauw", 1);
		Poll p = new Poll("Kleuren", options);
		boolean worked = p.vote("Blauw");
		assert worked;
		assertThat(p.getOptions().get("Blauw").equals(2));
	}

	/*
	@Test
	public void equalsContract() {
		try {
			EqualsVerifier.forClass(Poll.class)
				.withPrefabValues(User.class, new User("user", "pass"), new User("bla", "bla"))
				.usingGetClass()
				.verify();
		} catch (Exception e) {
			fail(e.getMessage());
		}
	}*/
}

@@ -182,16 +182,64 @@
 rtThat;%0A
+import static org.junit.Assert.assertNotEquals;%0A
 //import
@@ -1278,24 +1278,25 @@
 r(newUser);%0A
+%0A
 %09%09assertThat
@@ -1595,16 +1595,252 @@
 ));%0A%09%7D%0A%0A
+%09@Test%0A%09public void equalsTest() %7B%0A%09%09// not equal to meme%0A%09%09Object o = new Object();%0A%09%09HashMap%3CString, Integer%3E options = new HashMap%3C%3E();%0A%09%09options.put(%22Blauw%22, 1);%0A%09%09Poll p = new Poll(%22Kleuren%22, options);%0A%09%09assertNotEquals(p, o);%0A%09%7D%0A%0A
 %09/*%0A%09@Te

test comparison with object