/*
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
 */
package com.montealegreluis.yelpv3;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import static com.montealegreluis.yelpv3.Attribute.*;
import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;

public class SearchCriteriaTest {
    @Test
    public void it_does_not_allow_a_radius_bigger_than_40000_meters() {
        exception.expect(RuntimeException.class);

        SearchCriteria
            .byLocation("San Antonio")
            .withinARadiusOf(40001)
        ;
    }

    @Test
    public void it_does_not_allow_more_than_50_results() {
        exception.expect(RuntimeException.class);

        SearchCriteria
            .byCoordinates(29.426786, -98.489576)
            .limit(51)
        ;
    }

    @Test
    public void it_adds_several_attributes() {
        SearchCriteria criteria = SearchCriteria
            .byLocation("San Antonio")
            .withAttributes(CASHBACK, DEALS, GENDER_NEUTRAL_RESTROOMS)
        ;

        assertThat(
            criteria.toString(),
            containsString("cashback,deals,gender_neutral_restrooms")
        );
    }

    @Rule
    public ExpectedException exception = ExpectedException.none();
}
@@ -227,16 +227,43 @@
 ption;%0A%0A
+import java.time.Instant;%0A%0A
 import s
@@ -308,16 +308,16 @@
 bute.*;%0A
-
 import s
@@ -549,32 +549,28 @@
 .expect(
-RuntimeException
+AreaTooLarge
 .class);
@@ -784,24 +784,22 @@
 ect(
-RuntimeException
+TooManyResults
 .cla
@@ -902,39 +902,354 @@
 t(51)%0A        ;%0A
-
     %7D%0A%0A
+    @Test%0A    public void it_does_not_allow_searches_with_open_at_and_open_now() %7B%0A        exception.expect(IncompatibleCriteria.class);%0A%0A        SearchCriteria%0A            .byCoordinates(29.426786, -98.489576)%0A            .onlyOpenBusinesses()%0A            .openAt(Instant.now().getEpochSecond())%0A        ;%0A    %7D%0A%0A%0A
     @Test%0A    pu

Update test to check specific exceptions