Package org.onebusaway.transit_data_federation.services.service_alerts.ServiceAlerts

Examples of org.onebusaway.transit_data_federation.services.service_alerts.ServiceAlerts.ServiceAlert


        _alertsById.remove(id);
        _serviceAlertService.removeServiceAlert(id);
      } else {
        ServiceAlert.Builder serviceAlertBuilder = _alertLibrary.getAlertAsServiceAlert(
            id, alert);
        ServiceAlert serviceAlert = serviceAlertBuilder.build();
        ServiceAlert existingAlert = _alertsById.get(id);
        if (existingAlert == null || !existingAlert.equals(serviceAlert)) {
          _alertsById.put(id, serviceAlert);
          _serviceAlertService.createOrUpdateServiceAlert(serviceAlertBuilder,
              _agencyIds.get(0));
        }
      }
View Full Code Here


  }

  @Test
  public void testCreateServiceAlert() {
    ServiceAlert.Builder builder = ServiceAlert.newBuilder();
    ServiceAlert serviceAlert = _service.createOrUpdateServiceAlert(builder,
        "1");

    assertTrue(serviceAlert.hasCreationTime());
    assertTrue(serviceAlert.hasId());
    assertEquals("1", serviceAlert.getId().getAgencyId());
  }
View Full Code Here

  }

  @Test
  public void testSerialization() throws IOException {
    ServiceAlert.Builder builder = ServiceAlert.newBuilder();
    ServiceAlert serviceAlert = _service.createOrUpdateServiceAlert(builder,
        "1");

    FileInputStream in = new FileInputStream(_serviceAlertsPath);
    ServiceAlertsCollection collection = ServiceAlertsCollection.parseFrom(in);
    in.close();

    assertEquals(1, collection.getServiceAlertsCount());
    ServiceAlert read = collection.getServiceAlerts(0);
    assertEquals(serviceAlert.getId().getAgencyId(), read.getId().getAgencyId());
    assertEquals(serviceAlert.getId().getId(), read.getId().getId());
    assertEquals(serviceAlert.getCreationTime(), read.getCreationTime());
  }
View Full Code Here

  }

  @Test
  public void testGetAllServiceAlerts() {
    ServiceAlert.Builder builder1 = ServiceAlert.newBuilder();
    ServiceAlert serviceAlert1 = _service.createOrUpdateServiceAlert(builder1,
        "1");

    ServiceAlert.Builder builder2 = ServiceAlert.newBuilder();
    ServiceAlert serviceAlert2 = _service.createOrUpdateServiceAlert(builder2,
        "1");

    List<ServiceAlert> alerts = _service.getAllServiceAlerts();
    assertEquals(2, alerts.size());
    assertTrue(alerts.contains(serviceAlert1));
View Full Code Here

    // No publication window
    ServiceAlert.Builder builder1 = ServiceAlert.newBuilder();
    Affects.Builder builderForValue = Affects.newBuilder();
    builderForValue.setAgencyId(agencyId);
    builder1.addAffects(builderForValue);
    ServiceAlert serviceAlert1 = _service.createOrUpdateServiceAlert(builder1,
        agencyId);

    // Time is not supported by SituationQueryBean anymore, but leaving these
    // here for future reference.
    // Open-ended publication window ends in the past, should get filtered out
    ServiceAlert serviceAlert2 = addServiceAlertWithTimeRange(agencyId,
        createTimeRange(0, System.currentTimeMillis()));

    // Closed publication window starts in future, should get filtered out
    ServiceAlert serviceAlert3 = addServiceAlertWithTimeRange(
        agencyId,
        createTimeRange(System.currentTimeMillis() + (60 * 60 * 1000),
            System.currentTimeMillis() + (60 * 60 * 1000 * 2)));

    // Closed publication window contains time, should get included
    ServiceAlert serviceAlert4 = addServiceAlertWithTimeRange(
        agencyId,
        createTimeRange(System.currentTimeMillis() - (60 * 60 * 1000),
            System.currentTimeMillis() + (60 * 60 * 1000)));

    SituationQueryBean query = new SituationQueryBean();
View Full Code Here

    ServiceAlert.Builder builder2 = ServiceAlert.newBuilder();
    Affects.Builder builderForValue2 = Affects.newBuilder();
    builderForValue2.setAgencyId(agencyId);
    builder2.addAffects(builderForValue2);
    builder2.addPublicationWindow(timeRange);
    ServiceAlert serviceAlert2 = _service.createOrUpdateServiceAlert(builder2,
        agencyId);
    return serviceAlert2;
  }
View Full Code Here

  public void testGetServiceAlertsForFederatedAgencyId() {
    ServiceAlert.Builder builder = ServiceAlert.newBuilder();
    Affects.Builder affects = Affects.newBuilder();
    affects.setAgencyId("2");
    builder.addAffects(affects);
    ServiceAlert serviceAlert = _service.createOrUpdateServiceAlert(builder,
        "1");

    List<ServiceAlert> alerts = _service.getServiceAlertsForFederatedAgencyId("1");
    assertEquals(1, alerts.size());
    assertTrue(alerts.contains(serviceAlert));
View Full Code Here

  }

  @Test
  public void testGetServiceAlertForId() {
    ServiceAlert.Builder builder1 = ServiceAlert.newBuilder();
    ServiceAlert serviceAlert1 = _service.createOrUpdateServiceAlert(builder1,
        "1");

    ServiceAlert.Builder builder2 = ServiceAlert.newBuilder();
    ServiceAlert serviceAlert2 = _service.createOrUpdateServiceAlert(builder2,
        "1");

    ServiceAlert alert = _service.getServiceAlertForId(ServiceAlertLibrary.agencyAndId(serviceAlert1.getId()));
    assertSame(serviceAlert1, alert);

    alert = _service.getServiceAlertForId(ServiceAlertLibrary.agencyAndId(serviceAlert2.getId()));
    assertSame(serviceAlert2, alert);
View Full Code Here

  public void testGetServiceAlertsForAgencyId() {
    ServiceAlert.Builder builder = ServiceAlert.newBuilder();
    Affects.Builder affects = Affects.newBuilder();
    affects.setAgencyId("2");
    builder.addAffects(affects);
    ServiceAlert serviceAlert = _service.createOrUpdateServiceAlert(builder,
        "1");

    List<ServiceAlert> alerts = _service.getServiceAlertsForAgencyId(
        System.currentTimeMillis(), "1");
    assertEquals(0, alerts.size());
View Full Code Here

    ServiceAlert.Builder builder1 = ServiceAlert.newBuilder();
    Affects.Builder affects1 = Affects.newBuilder();
    affects1.setStopId(ServiceAlertLibrary.id("1", "10020"));
    affects1.setTripId(ServiceAlertLibrary.id("1", "TripA"));
    builder1.addAffects(affects1);
    ServiceAlert serviceAlert1 = _service.createOrUpdateServiceAlert(builder1,
        "1");

    ServiceAlert.Builder builder2 = ServiceAlert.newBuilder();
    Affects.Builder affects2 = Affects.newBuilder();
    affects2.setTripId(ServiceAlertLibrary.id("1", "TripA"));
    builder2.addAffects(affects2);
    ServiceAlert serviceAlert2 = _service.createOrUpdateServiceAlert(builder2,
        "1");

    ServiceAlert.Builder builder3 = ServiceAlert.newBuilder();
    Affects.Builder affects3 = Affects.newBuilder();
    affects3.setRouteId(ServiceAlertLibrary.id("1", "RouteX"));
    builder3.addAffects(affects3);
    ServiceAlert serviceAlert3 = _service.createOrUpdateServiceAlert(builder3,
        "1");

    ServiceAlert.Builder builder4 = ServiceAlert.newBuilder();
    Affects.Builder affects4 = Affects.newBuilder();
    affects4.setRouteId(ServiceAlertLibrary.id("1", "RouteX"));
    affects4.setDirectionId("1");
    builder4.addAffects(affects4);
    ServiceAlert serviceAlert4 = _service.createOrUpdateServiceAlert(builder4,
        "1");

    /**
     * These alerts shouldn't match
     */
 
View Full Code Here

TOP

Related Classes of org.onebusaway.transit_data_federation.services.service_alerts.ServiceAlerts.ServiceAlert

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.