diff --git a/src/main/java/com/github/curriculeon/Person.java b/src/main/java/com/github/curriculeon/Person.java index 3c8350b..76cbfaf 100644 --- a/src/main/java/com/github/curriculeon/Person.java +++ b/src/main/java/com/github/curriculeon/Person.java @@ -1,5 +1,23 @@ package com.github.curriculeon; public class Person { + public final Long id; + public String name; + public Person(Long id, String name) { + this.id = id; + this.name = name; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public Long getId() { + return id; + } } diff --git a/src/test/java/com/github/curriculeon/TestPerson.java b/src/test/java/com/github/curriculeon/TestPerson.java index 6c523fe..f43f312 100644 --- a/src/test/java/com/github/curriculeon/TestPerson.java +++ b/src/test/java/com/github/curriculeon/TestPerson.java @@ -1,5 +1,37 @@ package com.github.curriculeon; +import org.junit.Assert; +import org.junit.Test; + public class TestPerson { + @Test + public void testConstructor() { + //given + Long expectedId = 0L; + String expectedName = "Some name"; + + //when + Person person = new Person(expectedId, expectedName); + String actualName = person.getName(); + Long actualId = person.getId(); + + //then + Assert.assertEquals(expectedId, actualId); + Assert.assertEquals(expectedName, actualName); + } + + @Test + public void testSetName() { + //given + Person person = new Person(null, null); + String expectedName = "Some Name"; + Assert.assertNotEquals(expectedName, person.getName()); + + //when + person.setName(expectedName); + String actualName = person.getName(); + //then + Assert.assertEquals(expectedName, actualName); + } }