protected void assertBootUpState() throws Exception { // Assert state List<MobileObject> beans = this.runner.getDeviceDatabase().readByStorage(this.runner.getService()); assertTrue( "On Device Ticket service should not be empty!!!", (beans != null && !beans.isEmpty())); int loadedCount = 0; for (MobileObject currBean : beans) { if (!currBean.isProxy()) { loadedCount++; this.assertBean(currBean, (Ticket) this.ticketConnector.read(currBean.getServerRecordId())); } } assertTrue("On Device Ticket service should only have 2 loaded tickets", loadedCount == 2); }
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(); }
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); }