Search in sources :

Example 6 with OpeningHours

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

the class OpeningHoursValueParserTest method isNonStop3.

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

Example 7 with OpeningHours

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

the class OpeningTimeValueParserTest method parseDays3.

@Test
public void parseDays3() {
    OpeningTime openingTime = new OpeningTime();
    OpeningMonth openingMonth = new OpeningMonth();
    OpeningHours openingHours = new OpeningHours();
    openingMonth.addOpeningHours(openingHours);
    openingHours.setDayActivated(0, true);
    openingHours.setDayActivated(1, true);
    openingHours.setDayActivated(2, true);
    openingHours.setDayActivated(3, true);
    openingHours.setDayActivated(4, true);
    openingHours.setDayActivated(5, true);
    openingHours.setDayActivated(6, true);
    openingHours.setDayActivated(5, false);
    openingTime.addOpeningMonth(openingMonth);
    Assert.assertEquals(parser.toValue(openingTime), "Mo-Fr,Su 08:00-18:00");
}
Also used : 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)

Example 8 with OpeningHours

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

the class OpeningTimeValueParserTest method parseOpeningHours1.

@Test
public void parseOpeningHours1() {
    OpeningTime openingTime = new OpeningTime();
    OpeningMonth openingMonth = new OpeningMonth();
    OpeningHours openingHours1 = new OpeningHours();
    OpeningHours openingHours2 = new OpeningHours();
    openingMonth.addOpeningHours(openingHours1);
    openingMonth.addOpeningHours(openingHours2);
    openingMonth.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));
    openingTime.addOpeningMonth(openingMonth);
    Assert.assertEquals(parser.toValue(openingTime), "Mar: We 08:00-18:00, Sa 05:30-17:30");
}
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)

Example 9 with OpeningHours

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

the class OpeningTimeValueParserTest method fromValue1.

@Test
public void fromValue1() {
    String value = "Apr-May: Mo-Fr 10:15-01:30";
    OpeningTime openingTime = parser.fromValue(value);
    OpeningTime openingTimeExpected = new OpeningTime();
    OpeningMonth openingMonth = new OpeningMonth();
    openingTimeExpected.addOpeningMonth(openingMonth);
    openingMonth.setMonthActivated(3, true);
    openingMonth.setMonthActivated(4, true);
    OpeningHours openingHours = new OpeningHours();
    openingMonth.addOpeningHours(openingHours);
    openingHours.setFromTime(new LocalTime(10, 15));
    openingHours.setToTime(new LocalTime(1, 30));
    Assert.assertEquals(openingTimeExpected, openingTime);
}
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)

Example 10 with OpeningHours

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

the class OpeningHoursValueParser method toValue.

@Override
public String toValue(List<OpeningHours> openingHours) {
    StringBuilder openingHoursBuilder = new StringBuilder();
    for (OpeningHours o : openingHours) {
        openingHoursBuilder.append(openingHoursBuilder.length() == 0 ? "" : HOURS_SEP);
        openingHoursBuilder.append(toSingleValue(o));
    }
    return openingHoursBuilder.toString();
}
Also used : OpeningHours(io.jawg.osmcontributor.model.utils.OpeningHours)

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