/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import org.junit.After;
import org.junit.AfterClass;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import teamnotepad.TeamNotepadModel;
import teamnotepad.entities.Note;
/**
*
* @author tmr
*/
public class ModelTests {
private TeamNotepadModel model;
public ModelTests() {
}
@BeforeClass
public static void setUpClass() {}
@AfterClass
public static void tearDownClass() {}
@Before
public void setUp() {
model = new TeamNotepadModel(true);
}
@After
public void tearDown() {
}
@Test
public void SuiteNameValidation(){
String tooShortName = "asd";
StringBuilder buffer = new StringBuilder(130);
for(int i=0; i< buffer.length(); i++){
buffer.append("a");
}
assertFalse(model.isNotesSuiteTitleValid(tooShortName));
assertFalse(model.isNotesSuiteTitleValid(buffer.toString()));
assertTrue(model.isNotesSuiteTitleValid("asdfq"));
}
@Test
public void AuthenticationTokenGenerate(){
String token = model.generateUserAuthToken();
System.out.println(token.length());
assertTrue(token.length() == 99 || token.length() == 100);
}
@Test
public void SerializeNote(){
String noteContent = "asdf 23 123 lkf aw e";
String noteTitle = "kdjoiewo3f lk okj ok jok32 okj sd ";
Note note = new Note();
note.setContent(noteContent);
note.setTitle(noteTitle);
String expectedOutput = "{\"title\": \"kdjoiewo3f lk okj ok jok32 okj sd \", \"content\": \"asdf 23 123 lkf aw e\"}";
String serializedNote = model.serializeNote(note);
assertTrue(serializedNote.equals(expectedOutput));
}
}