package edu.cmu.sv.ws.ssnoc.test;

import static org.junit.Assert.*;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

import javax.ws.rs.core.Response;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertThat;

import edu.cmu.sv.ws.ssnoc.dto.Message;
import edu.cmu.sv.ws.ssnoc.dto.User;
import edu.cmu.sv.ws.ssnoc.rest.MessageService;
import edu.cmu.sv.ws.ssnoc.rest.MessagesService;
import edu.cmu.sv.ws.ssnoc.rest.UserService;

public class WallMessageTest {

	@Before
	public void setUp() throws Exception {
		User user = new User();
		user.setUserName("foo");
		user.setPassword("1234");
		
		UserService userService = new UserService();
		userService.addUser(user);
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testSendMessageToPublicWall() {
		Message msg = new Message();
		msg.setAuthor("foo");
		Timestamp postedAt = new Timestamp(1234);
		msg.setPostedAt(postedAt);
		msg.setContent("test test lloyd owes a me a beer");
		
		MessageService msgService = new MessageService();
		Response response = msgService.addWallMessage("foo", msg);
		assertEquals(((Message)response.getEntity()).getContent(), "test test lloyd owes a me a beer");
	}

	@Test
	public void testGetAllMessagesFromPublicWall() {
		List<Message> messages = new ArrayList<Message>();
		List<Message> list = (List<Message>) new MessagesService();
		List<Message> result = list;
		assertThat(result, messages);		
	}
}

@@ -280,26 +280,56 @@
 .Assert.
-assertThat
+*;%0Aimport static org.hamcrest.core.Is.is
 ;%0A%0Aimpor
@@ -1358,55 +1358,88 @@
 %7B%0A%09%09
-List%3C
 Message
-%3E
  m
-essages = new ArrayList%3CMessage%3E
+sg = new Message();%0A%09%09MessagesService msgsService = new MessagesService
 ();%0A
@@ -1454,20 +1454,24 @@
 essage%3E 
-list
+messages
  = (List
@@ -1485,95 +1485,111 @@
 e%3E) 
-new MessagesService
+msgsService.loadWallMessages
 ();%0A%09%09
-List%3C
+for (
 Message
-%3E result = list;%0A%09%09assertThat(result, m
+ m : messages) %7B%0A%09%09%09assertTrue(m instanceof M
 essage
-s
 );
+%0A
 %09%09
+%7D
 %0A%09%7D%0A

Fix test case