Search in sources :

Example 16 with OpeningHours

use of io.jawg.osmcontributor.model.utils.OpeningHours in project osm-contributor by jawg.

the class OpeningHoursValueParserTest method isNonStop2.

@Test
public void isNonStop2() {
    OpeningHours openingHours = new OpeningHours();
    openingHours.setFromTime(new LocalTime(0, 0));
    openingHours.setToTime(new LocalTime(23, 50));
    openingHours.setDays(OpeningHours.Days.values());
    Assert.assertTrue(parser.isNonStop(openingHours));
}
Also used : LocalTime(org.joda.time.LocalTime) OpeningHours(io.jawg.osmcontributor.model.utils.OpeningHours) Test(org.junit.Test)

Example 17 with OpeningHours

use of io.jawg.osmcontributor.model.utils.OpeningHours in project osm-contributor by jawg.

the class OpeningHoursValueParserTest method isNonStop7.

@Test
public void isNonStop7() {
    OpeningHours openingHours = new OpeningHours();
    openingHours.setFromTime(new LocalTime(23, 59));
    openingHours.setToTime(new LocalTime(23, 58));
    openingHours.setDays(OpeningHours.Days.values());
    Assert.assertTrue(parser.isNonStop(openingHours));
}
Also used : LocalTime(org.joda.time.LocalTime) OpeningHours(io.jawg.osmcontributor.model.utils.OpeningHours) Test(org.junit.Test)

Example 18 with OpeningHours

use of io.jawg.osmcontributor.model.utils.OpeningHours in project osm-contributor by jawg.

the class OpeningHoursValueParserTest method isNonStop6.

@Test
public void isNonStop6() {
    OpeningHours openingHours = new OpeningHours();
    openingHours.setFromTime(new LocalTime(0, 2));
    openingHours.setToTime(new LocalTime(0, 1));
    openingHours.setDays(OpeningHours.Days.values());
    Assert.assertTrue(parser.isNonStop(openingHours));
}
Also used : LocalTime(org.joda.time.LocalTime) OpeningHours(io.jawg.osmcontributor.model.utils.OpeningHours) Test(org.junit.Test)

Example 19 with OpeningHours

use of io.jawg.osmcontributor.model.utils.OpeningHours in project osm-contributor by jawg.

the class OpeningHoursValueParserTest method fromOpeningHoursValue3.

@Test
public void fromOpeningHoursValue3() {
    String value = "07:30-17:30, Mo,Th 01:00-02:00";
    List<OpeningHours> openingHoursList = parser.fromValue(value);
    Assert.assertTrue(openingHoursList.size() == 2);
    // OPENING 1
    OpeningHours openingHours1 = openingHoursList.get(0);
    OpeningHours openingHours1Expected = new OpeningHours();
    openingHours1Expected.setAllDaysActivated(false);
    openingHours1Expected.setFromTime(new LocalTime(7, 30));
    openingHours1Expected.setToTime(new LocalTime(17, 30));
    Assert.assertEquals(openingHours1Expected, openingHours1);
    // OPENING 2
    OpeningHours openingHours2 = openingHoursList.get(1);
    OpeningHours openingHours2Expected = new OpeningHours();
    openingHours2Expected.setAllDaysActivated(false);
    openingHours2Expected.setDayActivated(0, true);
    openingHours2Expected.setDayActivated(3, true);
    openingHours2Expected.setFromTime(new LocalTime(1, 0));
    openingHours2Expected.setToTime(new LocalTime(2, 0));
    Assert.assertEquals(openingHours2Expected, openingHours2);
}
Also used : LocalTime(org.joda.time.LocalTime) OpeningHours(io.jawg.osmcontributor.model.utils.OpeningHours) Test(org.junit.Test)

Example 20 with OpeningHours

use of io.jawg.osmcontributor.model.utils.OpeningHours in project osm-contributor by jawg.

the class OpeningTimeValueParserTest method parseAllFields1.

@Test
public void parseAllFields1() {
    OpeningTime openingTime = new OpeningTime();
    OpeningMonth openingMonth1 = new OpeningMonth();
    OpeningHours openingHours1 = new OpeningHours();
    OpeningHours openingHours2 = new OpeningHours();
    openingMonth1.addOpeningHours(openingHours1);
    openingMonth1.addOpeningHours(openingHours2);
    openingMonth1.setMonthActivated(1, true);
    openingMonth1.setMonthActivated(2, true);
    openingHours1.setAllDaysActivated(false);
    openingHours1.setDayActivated(2, true);
    openingHours2.setAllDaysActivated(false);
    openingHours2.setDayActivated(5, true);
    openingHours2.setFromTime(new LocalTime(5, 30));
    openingHours2.setToTime(new LocalTime(17, 30));
    OpeningMonth openingMonth2 = new OpeningMonth();
    OpeningHours openingHours3 = new OpeningHours();
    OpeningHours openingHours4 = new OpeningHours();
    openingMonth2.addOpeningHours(openingHours3);
    openingMonth2.addOpeningHours(openingHours4);
    openingMonth2.setMonthActivated(3, true);
    openingMonth2.setMonthActivated(4, true);
    openingHours3.setAllDaysActivated(false);
    openingHours3.setDayActivated(6, true);
    openingHours4.setAllDaysActivated(false);
    openingHours4.setDayActivated(5, true);
    openingHours4.setFromTime(new LocalTime(8, 10));
    openingHours4.setToTime(new LocalTime(19, 45));
    openingTime.addOpeningMonth(openingMonth1);
    openingTime.addOpeningMonth(openingMonth2);
    Assert.assertEquals(parser.toValue(openingTime), "Feb-Mar: We 08:00-18:00, Sa 05:30-17:30; Apr-May: Su 08:00-18:00, Sa 08:10-19:45");
}
Also used : LocalTime(org.joda.time.LocalTime) OpeningMonth(io.jawg.osmcontributor.model.utils.OpeningMonth) OpeningTime(io.jawg.osmcontributor.model.utils.OpeningTime) OpeningHours(io.jawg.osmcontributor.model.utils.OpeningHours) Test(org.junit.Test)

Aggregations

OpeningHours (io.jawg.osmcontributor.model.utils.OpeningHours)26 Test (org.junit.Test)21 LocalTime (org.joda.time.LocalTime)17 OpeningMonth (io.jawg.osmcontributor.model.utils.OpeningMonth)12 OpeningTime (io.jawg.osmcontributor.model.utils.OpeningTime)9 View (android.view.View)2 EditText (android.widget.EditText)2 EditDaysDialogFragment (io.jawg.osmcontributor.ui.dialogs.EditDaysDialogFragment)2 PleaseApplyOpeningTimeChange (io.jawg.osmcontributor.ui.events.edition.PleaseApplyOpeningTimeChange)2