-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Note model: getters, unittesting, javadoc
- Loading branch information
1 parent
d98f0b9
commit 5718d91
Showing
3 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"id": 478020, | ||
"note": "" | ||
} |