Esempio n. 1
0
 private void assertPart(MobileObject deviceBean, int index, List<Part> parts) {
   if (parts != null) {
     for (Part part : parts) {
       if (deviceBean.getValue("parts[" + index + "].name").equals(part.getName())) {
         return;
       }
     }
   }
   assertTrue(
       "Parts(Indexed Property) are not properly synchronized!!! Missing Part=["
           + deviceBean.getValue("parts[" + index + "].id")
           + "],["
           + deviceBean.getValue("parts[" + index + "].name")
           + "]",
       false);
 }
Esempio n. 2
0
 private void assertNote(MobileObject deviceBean, int index, List<Note> notes) {
   if (notes != null) {
     for (Note note : notes) {
       if (deviceBean.getValue("notes[" + index + "].note").equals(note.getNote())) {
         return;
       }
     }
   }
   assertTrue(
       "Notes(Indexed Property) are not properly synchronized!!! Missing Note=["
           + deviceBean.getValue("notes[" + index + "].id")
           + "],["
           + deviceBean.getValue("notes[" + index + "].note")
           + "]",
       false);
 }
Esempio n. 3
0
  protected String createNewDeviceObject() throws Exception {
    List<MobileObject> beans =
        this.runner.getDeviceDatabase().readByStorage(this.runner.getService());

    // Create the new ticket on the device
    MobileObject bean = null;
    for (MobileObject cour : beans) {
      if (!cour.isProxy() && !cour.isCreatedOnDevice()) {
        bean = cour;
        break;
      }
    }

    MobileObject newTicket = new MobileObject();
    newTicket.setStorageId(bean.getStorageId());

    newTicket.setValue("name", "This new refrigerator is broken");

    // Referenced Nested Properties
    newTicket.setValue("customerInfo.id", bean.getValue("customerInfo.id"));
    newTicket.setValue("customerInfo.customerId", bean.getValue("customerInfo.customerId"));
    newTicket.setValue("customerInfo.name", bean.getValue("customerInfo.name"));
    newTicket.setValue("customerInfo.comments", bean.getValue("customerInfo.comments"));

    // Notes
    for (int i = 0; i < 2; i++) {
      BeanListEntry note = new BeanListEntry();
      note.setProperty("note", "note://" + i + "/added");
      IndexingAPIUtil.addBean(newTicket, "notes", note);
    }

    // Parts
    for (int i = 0; i < 2; i++) {
      BeanListEntry part = new BeanListEntry();
      part.setProperty("name", "part://" + i + "/added");
      IndexingAPIUtil.addBean(newTicket, "parts", part);
    }

    this.runner.create(newTicket);

    return newTicket.getRecordId();
  }
Esempio n. 4
0
  protected void updateDeviceObject(String objectId) throws Exception {
    List<MobileObject> beans =
        this.runner.getDeviceDatabase().readByStorage(this.runner.getService());
    MobileObject storedBean = null;
    for (MobileObject cour : beans) {
      if (cour.getValue("technician.name") != null && !cour.isProxy()) {
        storedBean = cour;
        break;
      }
    }

    MobileObject bean = this.runner.getDeviceDatabase().read(this.runner.getService(), objectId);

    bean.setValue("name", "name://updated");

    // Referenced Technician
    bean.setValue("technician.id", storedBean.getValue("technician.id"));
    bean.setValue("technician.employeeId", storedBean.getValue("technician.employeeId"));
    bean.setValue("technician.name", storedBean.getValue("technician.name"));
    bean.setValue("technician.status", storedBean.getValue("technician.status"));

    // Notes
    for (int i = 0; i < 2; i++) {
      BeanListEntry note = new BeanListEntry();
      note.setProperty("note", "note://" + i + "/updated");
      IndexingAPIUtil.addBean(bean, "notes", note);
    }

    // Parts
    for (int i = 0; i < 2; i++) {
      BeanListEntry part = new BeanListEntry();
      part.setProperty("name", "part://" + i + "/updated");
      IndexingAPIUtil.addBean(bean, "parts", part);
    }

    this.runner.update(bean);
  }
Esempio n. 5
0
 private void assertPart(MobileObject deviceBean, Part part) {
   BeanList deviceParts = IndexingAPIUtil.readList(deviceBean, "parts");
   for (int j = 0; j < deviceParts.size(); j++) {
     if (deviceBean.getValue("parts[" + j + "].name").equals(part.getName())) {
       return;
     }
   }
   assertTrue(
       "Parts(Indexed Property) are not properly synchronized!!! Missing Part=["
           + part.getId()
           + "],["
           + part.getName()
           + "]",
       false);
 }
Esempio n. 6
0
 private void assertNote(MobileObject deviceBean, Note note) {
   BeanList deviceNotes = IndexingAPIUtil.readList(deviceBean, "notes");
   for (int j = 0; j < deviceNotes.size(); j++) {
     if (deviceBean.getValue("notes[" + j + "].note").equals(note.getNote())) {
       return;
     }
   }
   assertTrue(
       "Notes(Indexed Property) are not properly synchronized!!! Missing Note=["
           + note.getId()
           + "],["
           + note.getNote()
           + "]",
       false);
 }
Esempio n. 7
0
  protected void assertBean(MobileObject deviceBean, Ticket serverBean) {
    // Asserting Object Ids
    if (!deviceBean.isCreatedOnDevice()) {
      assertEquals(
          "Object ids must match!!", deviceBean.getServerRecordId(), serverBean.getTicketId());
    }

    assertEquals("Ticket Names must match!!", deviceBean.getValue("name"), serverBean.getName());

    // Asserting Nested Properties
    if (serverBean.getCustomerInfo() != null) {
      assertEquals(
          "Customer Id must match!!",
          deviceBean.getValue("customerInfo.customerId"),
          serverBean.getCustomerInfo().getCustomerId());
      assertEquals(
          "Customer Name must match!!",
          deviceBean.getValue("customerInfo.name"),
          serverBean.getCustomerInfo().getName());
      assertEquals(
          "Customer Comments must match!!",
          deviceBean.getValue("customerInfo.comments"),
          serverBean.getCustomerInfo().getComments());
    }

    if (serverBean.getEquipment() != null) {
      assertEquals(
          "Equipment Name must match!!",
          deviceBean.getValue("equipment.name"),
          serverBean.getEquipment().getName());
    }

    if (serverBean.getTechnician() != null) {
      assertEquals(
          "Technician EmployeeId must match!!",
          deviceBean.getValue("technician.employeeId"),
          serverBean.getTechnician().getEmployeeId());
      assertEquals(
          "Technician Name must match!!",
          deviceBean.getValue("technician.name"),
          serverBean.getTechnician().getName());
      assertEquals(
          "Technician Status must match!!",
          deviceBean.getValue("technician.status"),
          serverBean.getTechnician().getStatus());
    }

    // Asserting Indexed Properties from Server to Device
    List<Note> notes = serverBean.getNotes();
    if (notes != null) {
      for (Note note : notes) {
        this.assertNote(deviceBean, note);
      }
    }

    List<Part> parts = serverBean.getParts();
    if (parts != null) {
      for (Part part : parts) {
        this.assertPart(deviceBean, part);
      }
    }

    // Asserting Indexed Properties from Device to Server
    BeanList deviceNotes = IndexingAPIUtil.readList(deviceBean, "notes");
    for (int i = 0; i < deviceNotes.size(); i++) {
      if (deviceBean.getValue("notes[" + i + "].note") != null) {
        this.assertNote(deviceBean, i, notes);
      }
    }

    BeanList deviceParts = IndexingAPIUtil.readList(deviceBean, "parts");
    for (int i = 0; i < deviceParts.size(); i++) {
      if (deviceBean.getValue("parts[" + i + "].name") != null) {
        this.assertPart(deviceBean, i, parts);
      }
    }
  }
Esempio n. 8
0
  protected void printDeviceBean(MobileObject currBean) {
    log.info("Local Bean Id=" + currBean.getRecordId());
    log.info("Remote Bean Id=" + currBean.getServerRecordId());
    log.info("Ticket Id=" + currBean.getValue("ticketId"));
    log.info("Ticket Name=" + currBean.getValue("name"));

    log.info("Customer DB Id=" + currBean.getValue("customerInfo.id"));
    log.info("Customer Id=" + currBean.getValue("customerInfo.customerId"));
    log.info("Customer Name=" + currBean.getValue("customerInfo.name"));
    log.info("Customer Comments=" + currBean.getValue("customerInfo.comments"));

    log.info("Technician Id=" + currBean.getValue("technician.id"));
    log.info("Employee Id=" + currBean.getValue("technician.employeeId"));
    log.info("Technician Name=" + currBean.getValue("technician.name"));
    log.info("Technician Status=" + currBean.getValue("technician.status"));

    log.info("Equipment ID=" + currBean.getValue("equipment.id"));
    log.info("Equipment Name=" + currBean.getValue("equipment.name"));

    // Use better indexing API
    BeanList notes = IndexingAPIUtil.readList(currBean, "notes");
    for (int j = 0; j < notes.size(); j++) {
      BeanListEntry note = notes.getEntryAt(j);
      log.info("Note ID=" + note.getProperty("id"));
      log.info("Note=" + note.getProperty("note"));
    }

    // Use better indexing API
    BeanList parts = IndexingAPIUtil.readList(currBean, "parts");
    for (int j = 0; j < parts.size(); j++) {
      BeanListEntry part = parts.getEntryAt(j);
      log.info("Part ID=" + part.getProperty("id"));
      log.info("Part=" + part.getProperty("name"));
    }

    log.info("-----------------------------------------");
  }