@Test
  public void shouldCallAuditServiceAfterFormProcessing() {
    HashMap<String, Object> form1 =
        new HashMap<String, Object>() {
          {
            put(SERVER_VERSION, "120");
          }
        };
    HashMap<String, Object> form2 =
        new HashMap<String, Object>() {
          {
            put(SERVER_VERSION, "420");
          }
        };
    ArrayList<Map<String, Object>> allForms = newArrayList(form1, form2);
    ArrayList<Map<String, Object>> processForms = newArrayList(form2);

    when(auditService.getLastAudit()).thenReturn(Audit.DEFAULT);
    when(configuration.getPollingUrl()).thenReturn("www.localhost.com/form");
    when(httpClient.call(any(), anyString(), anyString())).thenReturn(allForms);
    when(formService.save(any())).thenReturn(processForms);

    jobScheduler.process();

    verify(auditService).createAuditFor(processForms, allForms);
  }
  @Test
  public void shouldAddTheDefaultTimestampValueOfZeroWhenTheLastAuditIsNull()
      throws URISyntaxException {
    String pollingUrl = "www.localhost.com/form";

    when(auditService.getLastAudit()).thenReturn(Audit.DEFAULT);
    when(configuration.getPollingUrl()).thenReturn(pollingUrl);
    when(configuration.getPollingUrlUsername()).thenReturn("admin");
    when(configuration.getPollingUrlPassword()).thenReturn("password");
    when(formService.save(any())).thenReturn(newArrayList());

    jobScheduler.process();

    verify(httpClient).call(new URI("www.localhost.com/form?timestamp=0"), "admin", "password");
  }
  @Test
  public void shouldReplaceTheLastTimestampFromTheLastAuditBeforePolling()
      throws URISyntaxException {
    Audit lastPolledAudit = new Audit(420L, 100L, 100L);
    String pollingUrl = "www.localhost.com/form?timestamp=0";

    when(auditService.getLastAudit()).thenReturn(lastPolledAudit);
    when(configuration.getPollingUrl()).thenReturn(pollingUrl);
    when(configuration.getPollingUrlUsername()).thenReturn("admin");
    when(configuration.getPollingUrlPassword()).thenReturn("password");
    when(formService.save(any())).thenReturn(newArrayList());

    jobScheduler.process();

    verify(httpClient).call(new URI("www.localhost.com/form?timestamp=420"), "admin", "password");
  }