Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Fix SlugEntityBaseTest
Browse files Browse the repository at this point in the history
  • Loading branch information
seanf committed Jul 10, 2013
1 parent 20b8d7a commit 5317a11
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Expand Up @@ -40,7 +40,7 @@
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class SlugEntityBase extends ModelEntityBase
public abstract class SlugEntityBase extends ModelEntityBase
{

private static final long serialVersionUID = -1911540675412928681L;
Expand Down
Expand Up @@ -20,8 +20,9 @@
*/
package org.zanata.model;

import lombok.NoArgsConstructor;

import org.testng.annotations.Test;
import org.zanata.common.EntityStatus;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
Expand All @@ -32,21 +33,29 @@
*/
public class SlugEntityBaseTest
{
@NoArgsConstructor
static class SlugClass extends SlugEntityBase
{
public SlugClass(String slug)
{
super(slug);
}
}
@Test
public void lombokToStringAndEqualsTest() {
SlugEntityBase entity = new SlugEntityBase();
SlugEntityBase entity = new SlugClass();

entity.setSlug("abc");
entity.setId(1L);
entity.setVersionNum(2);
assertThat(entity.toString(), containsString("[id=1,versionNum=2], slug=abc, status=ACTIVE)"));
assertThat(entity.toString(), containsString("[id=1,versionNum=2], slug=abc)"));

SlugEntityBase other = new SlugEntityBase("abc", EntityStatus.ACTIVE);
SlugEntityBase other = new SlugClass("abc");
assertThat(entity.equals(other), equalTo(false));

other.setId(entity.getId());
other.setVersionNum(entity.getVersionNum());
assertThat(entity.equals(other), equalTo(true));
assertThat(entity, equalTo(other));

assertThat(entity.hashCode(), equalTo(other.hashCode()));

Expand Down

0 comments on commit 5317a11

Please sign in to comment.