Skip to content

Commit

Permalink
Note model: getters, unittesting, javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianmacarescu committed May 27, 2016
1 parent d98f0b9 commit 5718d91
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/main/bookingbugAPI/models/Note.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package bookingbugAPI.models;

import helpers.HttpServiceResponse;

/**
* Created by User on 25.05.2016.
*/
public class Note extends BBRoot {

public Note(){}

public Note(HttpServiceResponse httpServiceResponse) {
super(httpServiceResponse);
}

/**
* Returns the note id.
*
* @return The note id associated with the Note Object
*/
public Integer getId() {
return getInteger("id", INTEGER_DEFAULT_VALUE);
}

/**
* Returns the note text.
*
* @return The note text associated with the Note Object
*/
public String getNote() {
return get("note");
}
}
40 changes: 40 additions & 0 deletions src/test/bookingbugAPI/models/NoteTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package bookingbugAPI.models;

import helpers.HttpServiceResponse;
import helpers.Utils;
import org.json.simple.JSONObject;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.text.ParseException;

import static org.junit.Assert.assertTrue;

/**
* Created by User on 25.05.2016.
*/
public class NoteTest extends ModelTest {
private JSONObject jsonObject;

@Override
@Before
public void setUp() {
jsonObject = getJSON("json/note.json");
}

@Override
@Test
public void modelInit() throws ParseException {
Note note = new Note(new HttpServiceResponse(Utils.stringToContentRep(jsonObject.toString())));

assertTrue(note.getId().toString().equals(jsonObject.get("id").toString()));
assertTrue(note.getNote().equals(jsonObject.get("note")));
}

@Override
@After
public void tearDown() {
jsonObject = null;
}
}
4 changes: 4 additions & 0 deletions src/test/resources/json/note.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"id": 478020,
"note": ""
}

0 comments on commit 5718d91

Please sign in to comment.