Created
July 21, 2009 07:47
-
-
Save bigeasy/151188 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.goodworkalan.prattle.model; | |
import java.io.Serializable; | |
public class Person implements Serializable | |
{ | |
private static final long serialVersionUID = 1L; | |
private String firstName; | |
private String lastName; | |
private int hatSize; | |
public Person() | |
{ | |
} | |
public Person(String firstName, String lastName, int hatSize) | |
{ | |
this.firstName = firstName; | |
this.lastName = lastName; | |
this.hatSize = hatSize; | |
} | |
public String getFirstName() | |
{ | |
return firstName; | |
} | |
public void setFirstName(String firstName) | |
{ | |
this.firstName = firstName; | |
} | |
public String getLastName() | |
{ | |
return lastName; | |
} | |
public void setLastName(String lastName) | |
{ | |
this.lastName = lastName; | |
} | |
public int getHatSize() | |
{ | |
return hatSize; | |
} | |
public void setHatSize(int hatSize) | |
{ | |
this.hatSize = hatSize; | |
} | |
@Override | |
public boolean equals(Object object) | |
{ | |
if (object instanceof Person) | |
{ | |
Person person = (Person) object; | |
return firstName.equals(person.firstName) | |
&& lastName.equals(person.lastName) | |
&& hatSize == person.hatSize; | |
} | |
return false; | |
} | |
@Override | |
public int hashCode() | |
{ | |
return 1; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.goodworkalan.prattle.yaml; | |
import static org.testng.Assert.assertEquals; | |
import java.io.IOException; | |
import org.testng.annotations.Test; | |
import org.yaml.snakeyaml.Yaml; | |
import com.goodworkalan.prattle.model.Person; | |
public class PrattleRepresenterTest | |
{ | |
@Test | |
public void test() throws IOException | |
{ | |
Yaml yaml = new Yaml(); | |
Person person = new Person("Alan", "Gutierrez", 9); | |
assertEquals(person, yaml.load(yaml.dump(person))); | |
assertEquals(person, yaml.load(yaml.dump(person))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment