@Test public void updatePropertiesWithLastAuditId_noAuditsFound() throws Exception { replay(propertyFileManager, auditApplicationRestClient, applicationEventPublisher); try { unit.updatePropertiesWithLastAuditId("lastAuditIdKey", emptyAuditResponse); } catch (JSONException e) { System.out.println("in catch block"); fail("Shouldn't have JSON exceptions for an empty audit response - " + e.getMessage()); } verify(propertyFileManager, auditApplicationRestClient, applicationEventPublisher); }
protected void updatePropertiesWithLastAuditId(String lastAuditIdKey, JSONObject fullAuditResponse) { JSONArray allAudits = fullAuditResponse.getJSONArray("entries"); int numAudits = allAudits.length(); if (numAudits > 0) { long lastAuditFromFullResponse = allAudits.getJSONObject(numAudits - 1).getLong("id"); Map<String, String> properties = Collections.singletonMap(lastAuditIdKey, String.valueOf(lastAuditFromFullResponse)); getPropertyFileManager().storeMultiple(properties, getAuditApplicationLastAuditIdsFilename(), false); } }
AlfrescoSyncService implements ApplicationEventPublisherAware { protected void updatePropertiesWithLastAuditId(String lastAuditIdKey, JSONObject fullAuditResponse) { JSONArray allAudits = fullAuditResponse.getJSONArray("entries"); int numAudits = allAudits.length(); if (numAudits > 0) { long lastAuditFromFullResponse = allAudits.getJSONObject(numAudits - 1).getLong("id"); Map<String, String> properties = Collections.singletonMap(lastAuditIdKey, String.valueOf(lastAuditFromFullResponse)); getPropertyFileManager().storeMultiple(properties, getAuditApplicationLastAuditIdsFilename(), false); } } }
AlfrescoSyncService implements ApplicationEventPublisherAware { protected void updatePropertiesWithLastAuditId(String lastAuditIdKey, JSONObject fullAuditResponse) { JSONArray allAudits = fullAuditResponse.getJSONArray("entries"); int numAudits = allAudits.length(); if (numAudits > 0) { long lastAuditFromFullResponse = allAudits.getJSONObject(numAudits - 1).getLong("id"); Map<String, String> properties = Collections.singletonMap(lastAuditIdKey, String.valueOf(lastAuditFromFullResponse)); getPropertyFileManager().storeMultiple(properties, getAuditApplicationLastAuditIdsFilename(), false); } }  }
AlfrescoSyncService implements ApplicationEventPublisherAware { protected void updatePropertiesWithLastAuditId(String lastAuditIdKey, JSONObject fullAuditResponse) { JSONArray allAudits = fullAuditResponse.getJSONArray("entries"); int numAudits = allAudits.length(); if (numAudits > 0) { long lastAuditFromFullResponse = allAudits.getJSONObject(numAudits - 1).getLong("id"); Map<String, String> properties = Collections.singletonMap(lastAuditIdKey, String.valueOf(lastAuditFromFullResponse)); getPropertyFileManager().storeMultiple(properties, getAuditApplicationLastAuditIdsFilename(), false); } }  void queryAlfrescoAuditApplications(); PropertyFileManager getPropertyFileManager(); void setPropertyFileManager(PropertyFileManager propertyFileManager); AlfrescoAuditApplicationRestClient getAuditApplicationRestClient(); void setAuditApplicationRestClient(AlfrescoAuditApplicationRestClient auditApplicationRestClient); String getAuditApplicationLastAuditIdsFilename(); void setAuditApplicationLastAuditIdsFilename(String auditApplicationLastAuditIdsFilename); @Override void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher); Map<String, EcmAuditResponseReader> getAuditApplications(); void setAuditApplications(Map<String, EcmAuditResponseReader> auditApplications); }
AlfrescoSyncService implements ApplicationEventPublisherAware { protected void updatePropertiesWithLastAuditId(String lastAuditIdKey, JSONObject fullAuditResponse) { JSONArray allAudits = fullAuditResponse.getJSONArray("entries"); int numAudits = allAudits.length(); if (numAudits > 0) { long lastAuditFromFullResponse = allAudits.getJSONObject(numAudits - 1).getLong("id"); Map<String, String> properties = Collections.singletonMap(lastAuditIdKey, String.valueOf(lastAuditFromFullResponse)); getPropertyFileManager().storeMultiple(properties, getAuditApplicationLastAuditIdsFilename(), false); } }  void queryAlfrescoAuditApplications(); PropertyFileManager getPropertyFileManager(); void setPropertyFileManager(PropertyFileManager propertyFileManager); AlfrescoAuditApplicationRestClient getAuditApplicationRestClient(); void setAuditApplicationRestClient(AlfrescoAuditApplicationRestClient auditApplicationRestClient); String getAuditApplicationLastAuditIdsFilename(); void setAuditApplicationLastAuditIdsFilename(String auditApplicationLastAuditIdsFilename); @Override void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher); Map<String, EcmAuditResponseReader> getAuditApplications(); void setAuditApplications(Map<String, EcmAuditResponseReader> auditApplications);  }