8000 Merge remote-tracking branch 'origin/master' · blackbeltcoder/Todoo@915b7e8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 915b7e8

Browse files
Merge remote-tracking branch 'origin/master'
2 parents 6f97cb3 + f66b18a commit 915b7e8

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

src/main/java/com/sar/sandpit/ItemService.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ public boolean updateItem(Item item) {
2020

2121
@Override
2222
public Item getItem(long id) {
23-
24-
itemStore.findOne(id);
25-
return null;
26-
//return new Item();
23+
return itemStore.findOne(id);
2724
}
2825

2926
public ItemService(ItemStorable itemStorable) {

src/test/java/com/sar/sandpit/ItemControllerTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ public void displayItem_StoreHasOneItem_Success() throws Exception {
2222

2323
throw new NotImplementedException();
2424

25+
2526

2627
}
28+
29+
2730
}

src/test/java/com/sar/sandpit/ItemServiceTest.java

Lines changed: 15 additions & 2 deletions
-
Item res =itemService.getItem(1L);
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,23 @@ public void getItem_success() throws Exception {
117117
@Test
118118
public void getItem_success2() throws Exception {
119119

120+
long id =1L;
120121
//Arrange
121-
when(itemStorable.findOne(1L)).thenReturn(new Item(1L));
122
122+
when(itemStorable.findOne(id)).thenReturn(new Item(id));
123+
Item res =itemService.getItem(id);
123124
assertThat("item not null", res, is(notNullValue()));
125+
assertThat("item not equal to id ",id,is(equalTo(res.getId())));
126+
127+
}
128+
@Test
129+
public void getItem_success3() throws Exception {
130+
131+
long id =2L;
132+
//Arrange
133+
when(itemStorable.findOne(id)).thenReturn(new Item(id));
134+
Item res =itemService.getItem(id);
135+
assertThat("item not null", res, is(notNullValue()));
136+
assertThat("item not equal to id ",id,is(equalTo(res.getId())));
124137

125138
}
126139

0 commit comments

Comments
 (0)
0