-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
Copy pathNotesCommandToNotesTest.java
49 lines (36 loc) · 1.23 KB
/
NotesCommandToNotesTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package guru.springframework.converters;
import guru.springframework.commands.NotesCommand;
import guru.springframework.domain.Notes;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class NotesCommandToNotesTest {
public static final Long ID_VALUE = new Long(1L);
public static final String RECIPE_NOTES = "Notes";
NotesCommandToNotes converter;
@BeforeEach
public void setUp() throws Exception {
converter = new NotesCommandToNotes();
}
@Test
public void testNullParameter() throws Exception {
assertNull(converter.convert(null));
}
@Test
public void testEmptyObject() throws Exception {
assertNotNull(converter.convert(new NotesCommand()));
}
@Test
public void convert() throws Exception {
//given
NotesCommand notesCommand = new NotesCommand();
notesCommand.setId(ID_VALUE);
notesCommand.setRecipeNotes(RECIPE_NOTES);
//when
Notes notes = converter.convert(notesCommand);
//then
assertNotNull(notes);
assertEquals(ID_VALUE, notes.getId());
assertEquals(RECIPE_NOTES, notes.getRecipeNotes());
}
}