Exemplo n.º 1
0
 @Test
 public void shouldTreatNullBoundariesAsNotExisting() {
   Place place = new Place();
   place.setWasFetchedAt(new Date());
   boolean res = Predicates.fetchTime(Interval.between((Date) null, null)).appliesTo(place);
   Assert.assertTrue(res);
 }
Exemplo n.º 2
0
 @Test
 public void shouldSurviveNotInitedClassInSqlLikeBehaviour() {
   Place place = new Place();
   place.setWasFetchedAt(new Date());
   boolean res = Predicates.fetchTime(null).appliesTo(place);
   Assert.assertFalse(res);
 }
Exemplo n.º 3
0
 @Test
 public void shouldNeqPageItWasFetchedFromIfItIsDifferent() {
   Place place = new Place();
   place.setWasFoundAt("aaa");
   boolean res = Predicates.wasFoundAt("aab").appliesTo(place);
   Assert.assertFalse(res);
 }
Exemplo n.º 4
0
 @Test
 public void shouldEqPageItWasFetchedFrom() {
   Place place = new Place();
   place.setWasFoundAt("aaa");
   boolean res = Predicates.wasFoundAt("aaa").appliesTo(place);
   Assert.assertTrue(res);
 }
Exemplo n.º 5
0
 @Test
 public void shouldMatchRightOpenConstraint() {
   Place place = new Place();
   place.setWasFetchedAt(new Date());
   Date twoMinsAgo = new Date(System.currentTimeMillis() - 1000 * 60 * 2);
   boolean res = Predicates.fetchTime(Interval.after(twoMinsAgo)).appliesTo(place);
   Assert.assertTrue(res);
 }
Exemplo n.º 6
0
  @Test
  public void shouldNeqToEverythingIfIsNull() {
    Place place = new Place();
    place.setWasFoundAt("aaa");
    boolean res = Predicates.wasFoundAt(null).appliesTo(place);
    Assert.assertFalse(res);

    place.setWasFoundAt(null);
    res = Predicates.wasFoundAt(null).appliesTo(place);
    Assert.assertFalse(res);
  }
Exemplo n.º 7
0
  @Test
  public void shouldMatchLeftOpenConstraint() {
    Place place = new Place();
    Date now = new Date();
    place.setWasFetchedAt(now);
    Date twoMinsFwd = new Date(System.currentTimeMillis() + 1000 * 60 * 2);

    boolean res = Predicates.fetchTime(Interval.before(twoMinsFwd)).appliesTo(place);
    Assert.assertTrue(res);

    place.setWasFetchedAt(twoMinsFwd);
    res = Predicates.fetchTime(Interval.before(now)).appliesTo(place);
    Assert.assertFalse(res);
  }
Exemplo n.º 8
0
  @Test
  public void shouldMatchNullValueOnlyIfBothBoundariesAreOpen() {
    Place place = new Place();
    place.setWasFetchedAt(null);
    Date twoMinsAgo = new Date(System.currentTimeMillis() - 1000 * 60 * 2);
    Date twoMinsFwd = new Date(System.currentTimeMillis() + 1000 * 60 * 2);

    boolean res = Predicates.fetchTime(Interval.between(twoMinsAgo, twoMinsFwd)).appliesTo(place);
    Assert.assertFalse(res);

    res = Predicates.fetchTime(Interval.between(null, twoMinsFwd)).appliesTo(place);
    Assert.assertFalse(res);

    res = Predicates.fetchTime(Interval.between(twoMinsAgo, null)).appliesTo(place);
    Assert.assertFalse(res);

    res = Predicates.fetchTime(Interval.between((Date) null, null)).appliesTo(place);
    Assert.assertTrue(res);
  }
Exemplo n.º 9
0
 public String apply(Place arg0) {
   return arg0.getWasFoundAt();
 }
Exemplo n.º 10
0
 public Integer apply(Place arg0) {
   return arg0.getPriceUsd();
 }
Exemplo n.º 11
0
 public Date apply(Place arg0) {
   return arg0.getWasFetchedAt();
 }