Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/main/java/com/github/curriculeon/Person.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
32 changes: 32 additions & 0 deletions src/test/java/com/github/curriculeon/TestPerson.java
Original file line number Diff line number Diff line change
@@ -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);
}
}