Skip to content

Commit

Permalink
Verify #155 is fixed in Version 5
Browse files Browse the repository at this point in the history
  • Loading branch information
lincolnthree committed Dec 19, 2020
1 parent d7817fe commit 1ff0b49
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.ocpsoft.prettytime.impl.ResourcesTimeFormat;
import org.ocpsoft.prettytime.impl.ResourcesTimeUnit;
import org.ocpsoft.prettytime.units.Hour;
import org.ocpsoft.prettytime.units.JustNow;
import org.ocpsoft.prettytime.units.Minute;
Expand Down Expand Up @@ -86,6 +88,26 @@ public void testModifyUnitInPlace()
Assert.assertEquals("moments ago", prettyTime.format(LocalDateTime.now().minusSeconds(1)));
}

@Test
public void testRemoveAndReadUnit()
{
PrettyTime prettyTime = new PrettyTime();
prettyTime.removeUnit(JustNow.class);
ResourcesTimeUnit justNow = new ResourcesTimeUnit() {
{
setMaxQuantity(10000);
}

@Override
protected String getResourceKeyPrefix()
{
return "JustNow";
}
};
prettyTime.registerUnit(justNow, new ResourcesTimeFormat(justNow));
Assert.assertEquals("moments ago", prettyTime.format(LocalDateTime.now().minusSeconds(1)));
}

// Method tearDown() is called automatically after every test method
@After
public void tearDown() throws Exception
Expand Down

0 comments on commit 1ff0b49

Please sign in to comment.