Skip to content

Commit 5718d91

Browse files
Note model: getters, unittesting, javadoc
1 parent d98f0b9 commit 5718d91

3 files changed

Lines changed: 77 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package bookingbugAPI.models;
2+
3+
import helpers.HttpServiceResponse;
4+
5+
/**
6+
* Created by User on 25.05.2016.
7+
*/
8+
public class Note extends BBRoot {
9+
10+
public Note(){}
11+
12+
public Note(HttpServiceResponse httpServiceResponse) {
13+
super(httpServiceResponse);
14+
}
15+
16+
/**
17+
* Returns the note id.
18+
*
19+
* @return The note id associated with the Note Object
20+
*/
21+
public Integer getId() {
22+
return getInteger("id", INTEGER_DEFAULT_VALUE);
23+
}
24+
25+
/**
26+
* Returns the note text.
27+
*
28+
* @return The note text associated with the Note Object
29+
*/
30+
public String getNote() {
31+
return get("note");
32+
}
33+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package bookingbugAPI.models;
2+
3+
import helpers.HttpServiceResponse;
4+
import helpers.Utils;
5+
import org.json.simple.JSONObject;
6+
import org.junit.After;
7+
import org.junit.Before;
8+
import org.junit.Test;
9+
10+
import java.text.ParseException;
11+
12+
import static org.junit.Assert.assertTrue;
13+
14+
/**
15+
* Created by User on 25.05.2016.
16+
*/
17+
public class NoteTest extends ModelTest {
18+
private JSONObject jsonObject;
19+
20+
@Override
21+
@Before
22+
public void setUp() {
23+
jsonObject = getJSON("json/note.json");
24+
}
25+
26+
@Override
27+
@Test
28+
public void modelInit() throws ParseException {
29+
Note note = new Note(new HttpServiceResponse(Utils.stringToContentRep(jsonObject.toString())));
30+
31+
assertTrue(note.getId().toString().equals(jsonObject.get("id").toString()));
32+
assertTrue(note.getNote().equals(jsonObject.get("note")));
33+
}
34+
35+
@Override
36+
@After
37+
public void tearDown() {
38+
jsonObject = null;
39+
}
40+
}

src/test/resources/json/note.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"id": 478020,
3+
"note": ""
4+
}

0 commit comments

Comments
 (0)