Skip to content

fixing test #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
<groupId>com.zipcodewilmington</groupId>
<artifactId>person</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
Expand Down
71 changes: 68 additions & 3 deletions src/main/java/com/zipcodewilmington/person/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,97 @@
* Created by leon on 2/12/18.
*/
public class Person {


private String name;
private int age;
private String hairColor;
private int hait;
private String nationality;
private String favColor;
private String favSong;

public Person() {

public Person (String name, Integer age){
this.name = name;
this.age = age;
}



public Person(int age) {
this.age = age;

}

public Person(String name) {
this.name = name;
}

public Person(String name, int age) {
this.name = name;
this.age = age;
}

public void setName(String name) {
this.name = name;
}

public void setAge(int age) {
this.age = age;

}

public String getName() {
return null;
return name;
}

public Integer getAge() {
return null;
return age;
}



public void setHairColor(String hairColor) {
this.hairColor = hairColor;
}

public String getHairColor() {
return hairColor;
}


public void setHait(int hait) {
this.hait = hait;
}

public int getHait() {
return hait;
}


public void setNationality(String nationality) {
this.nationality = nationality;
}

public String getNationality() {
return nationality;
}

public void setFavoriteColor(String favColor) {
this.favColor= favColor;
}

public String getFavoriteColor(){
return favColor;
}


public void setFavoriteSong(String favSong) {
this.favSong = favSong;
}

public String getFavoriteSong(){
return favSong;
}
}
82 changes: 79 additions & 3 deletions src/test/java/com/zipcodewilmington/person/TestPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public void testDefaultConstructor() {
Integer expectedAge = Integer.MAX_VALUE;

// When
Person person = new Person();
Person person = new Person(expectedName, expectedAge);

// Then
String actualName = person.getName();
Expand Down Expand Up @@ -71,28 +71,104 @@ public void testConstructorWithNameAndAge() {
@Test
public void testSetName() {
// Given
Person person = new Person();
//Person person = new Person();
String expected = "Leon";

// When
Person person = new Person(expected);
person.setName(expected);
String actual = person.getName();

// Then
Assert.assertEquals(expected, actual);
System.out.println(actual);
}

@Test
public void testSetAge() {
// Given
Person person = new Person();
//Person person = new Person();
Integer expected = 5;

// When
Person person = new Person(expected);
person.setAge(expected);

// Then
Integer actual = person.getAge();
Assert.assertEquals(expected, actual);
}


@Test
public void testHairColorTest() {
//GIVEN
String expected = "blue";

//WHEN
Person person = new Person(expected);
person.setHairColor(expected);
String actual = person.getHairColor();

//THEN
Assert.assertEquals(expected, actual);
}

@Test
public void setHaitTest(){
//GIVEN
int expected = 4;

//WHEN
Person person = new Person(expected);
person.setHait(expected);
int actual = person.getHait();

//THEN
Assert.assertEquals(expected, actual);
}

@Test
public void setNationalityTest(){
//GIVEN
String expected = "Mexico";

//WHEN
Person person = new Person(expected);
person.setNationality(expected);
String actual = person.getNationality();

//THEN
Assert.assertEquals(expected, actual);
}

@Test
public void setFavoriteColorTest(){
//GIVEN
String expected = "pink";
//WHEN
Person person = new Person(expected);
person.setFavoriteColor(expected);
String actual = person.getFavoriteColor();
//THEN
Assert.assertEquals(expected, actual);

}



@Test
public void SetFavoriteSong(){
//GIVEN
String expected = "Dynamite";
//WHEN
Person person = new Person(expected);
person.setFavoriteSong(expected);
String actual = person.getFavoriteSong();
//THEN
Assert.assertEquals(expected, actual);
}



}