コード例 #1
0
  @Test
  public void storeAndGetJobSimpleJobSurvey() {
    this.clearDatabase();
    try {
      int step = 0;

      TimeBooking booking = TeztBeanSimpleFactory.getNewValidBooking();
      booking.setBooked();
      booking.insert();

      Job job = new Job();
      job.setUsername(TeztBeanSimpleFactory.getAdmin().getUsername());
      job.setStep(step);
      job.setJobSurvey(new JSONObject());
      job.setJobId(booking.getId());
      JobDataProcessing jdp = TeztBeanSimpleFactory.getNewValidJobDataProcessing();
      jdp.insertOrUpdate();
      job.setIdJobDataProcessing(jdp.getId());
      assertTrue(job.insertOrUpdate());

      Job back = CouchDBDao4Jobs.me().getJob(booking.getId(), step);
      assertNotNull(back);
    } catch (Exception e) {
      fail("should not throw exception " + e);
    }
  }
コード例 #2
0
  @SuppressWarnings("unchecked")
  @Test
  public void storeAndGetJob() {
    this.clearDatabase();
    try {
      int step = 0;
      Job job = new Job();
      job.setStep(step);
      JSONObject jobsurvey = new JSONObject();

      JSONObject jobsurvey2 = new JSONObject();
      jobsurvey2.put("input 2", "value 2");
      jobsurvey2.put("input 3", "value 3");

      JSONObject jobsurvey3 = new JSONObject();
      jobsurvey3.put("input 4", "value 4");
      jobsurvey3.put("input 5", "value 5");

      JSONArray innerarray = new JSONArray();
      innerarray.put("hallo 1");
      innerarray.put("hallo 2");

      JSONArray innerarray2 = new JSONArray();
      innerarray2.put("hallo 3");
      innerarray2.put("hallo 4");

      innerarray.put(innerarray2);
      innerarray.put(jobsurvey3);

      jobsurvey.put("input 0", "value 0");
      jobsurvey.put("input 1", "value 1");
      jobsurvey.put("innerobj", jobsurvey2);
      jobsurvey.put("innerarray", innerarray);

      job.setJobSurvey(jobsurvey);

      assertEquals(job.getJobSurvey().get("input 0").toString(), "value 0");
      assertEquals(job.getJobSurvey().get("input 1").toString(), "value 1");
      Map inner = (Map) job.getJobSurvey().get("innerobj");
      assertEquals(inner.get("input 2"), "value 2");

      job.setUsername(TeztBeanSimpleFactory.getAdmin().getUsername());
      TimeBooking booking = TeztBeanSimpleFactory.getNewValidBooking();
      booking.setBooked();
      booking.insert();
      job.setJobId(booking.getId());
      JobDataProcessing jdp = TeztBeanSimpleFactory.getNewValidJobDataProcessing();
      jdp.insertOrUpdate();
      job.setIdJobDataProcessing(jdp.getId());
      job.insertOrUpdate();

      Job back = CouchDBDao4Jobs.me().getJob(booking.getId(), step);
      assertNotNull(back);
      assertNotNull(back.getJobSurvey());
      assertEquals(back.getJobSurvey().get("input 0").toString(), "value 0");
      assertEquals(back.getJobSurvey().get("input 1").toString(), "value 1");
      Map innerback = (Map) back.getJobSurvey().get("innerobj");
      assertEquals(innerback.get("input 2"), "value 2");
    } catch (JSONException e) {
      fail("should not throw exception " + e);
    } catch (Exception e) {
      fail("should not throw exception " + e);
    }
  }