protected void updateServerObject(String ticketId) throws Exception { Ticket ticket = (Ticket) this.ticketConnector.read(ticketId); ticket.setName("name://updated"); List serverChangeLog = new ArrayList(); ChangeLogEntry serverEntry = new ChangeLogEntry(); serverEntry.setNodeId(this.runner.getService()); serverEntry.setOperation(ServerSyncEngine.OPERATION_UPDATE); serverEntry.setRecordId(ticketId); serverChangeLog.add(serverEntry); this.serverSyncEngine.addChangeLogEntries( this.runner.getDeviceId(), this.runner.getApp(), serverChangeLog); }
// ----------------------------------------------------------------------------------------------------------------------- protected String createNewServerObject() throws Exception { Ticket ticket = this.dataGenerator.generateTransientData("ticket://new"); String ticketId = this.ticketConnector.getTicketds().create(ticket); ticket = this.ticketConnector.getTicketds().readByTicketId(ticketId); List serverChangeLog = new ArrayList(); ChangeLogEntry serverEntry = new ChangeLogEntry(); serverEntry.setNodeId(this.runner.getService()); serverEntry.setOperation(ServerSyncEngine.OPERATION_ADD); serverEntry.setRecordId(ticket.getTicketId()); serverChangeLog.add(serverEntry); this.serverSyncEngine.addChangeLogEntries( this.runner.getDeviceId(), this.runner.getApp(), serverChangeLog); return ticket.getTicketId(); }
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); } } }
protected void printServerData() throws Exception { log.info("Dumping Server Data-----------------------------------------"); List<Ticket> tickets = this.ticketConnector.getTicketds().readAll(); for (Ticket ticket : tickets) { log.info("Local Bean Id=" + ticket.getTicketId()); log.info("Ticket Name=" + ticket.getName()); log.info("Customer DB Id=" + ticket.getCustomerInfo().getId()); log.info("Customer Id=" + ticket.getCustomerInfo().getCustomerId()); log.info("Customer Name=" + ticket.getCustomerInfo().getName()); log.info("Customer Comments=" + ticket.getCustomerInfo().getComments()); if (ticket.getTechnician() != null) { log.info("Technician Id=" + ticket.getTechnician().getId()); log.info("Employee Id=" + ticket.getTechnician().getEmployeeId()); log.info("Technician Name=" + ticket.getTechnician().getName()); log.info("Technician Status=" + ticket.getTechnician().getStatus()); } if (ticket.getEquipment() != null) { log.info("Equipment ID=" + ticket.getEquipment().getId()); log.info("Equipment Name=" + ticket.getEquipment().getName()); } List<Note> notes = ticket.getNotes(); if (notes != null) { for (Note note : notes) { log.info("Note ID=" + note.getId()); log.info("Note=" + note.getNote()); } } List<Part> parts = ticket.getParts(); if (parts != null) { for (Part part : parts) { log.info("Part ID=" + part.getId()); log.info("Part=" + part.getName()); } } log.info("-----------------------------------------"); } }