@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } if (!super.equals(o)) { return false; } LogWithNameAndProperties logWithNameAndProperties = (LogWithNameAndProperties) o; return name != null ? name.equals(logWithNameAndProperties.name) : logWithNameAndProperties.name == null; }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + (name != null ? name.hashCode() : 0); return result; } }
@Override public void read(JSONObject object) throws JSONException { super.read(object); setName(object.getString(NAME)); }
@Override public void read(JSONObject object) throws JSONException { super.read(object); setProperties(JSONUtils.readMap(object, PROPERTIES)); }
@Override public void write(JSONStringer writer) throws JSONException { super.write(writer); writer.key(NAME).value(getName()); }
@Override public void write(JSONStringer writer) throws JSONException { super.write(writer); JSONUtils.writeMap(writer, PROPERTIES, getProperties()); }
log.setProperties(properties); long id = persistence.putLog(log, "test-p1", PERSISTENCE_NORMAL); assertEquals(1, persistence.countLogs("test-p1"));
@Override public void write(JSONStringer writer) throws JSONException { super.write(writer); writer.key(ID).value(getId()); if (getException() != null) { writer.key(EXCEPTION).object(); exception.write(writer); writer.endObject(); } }
Map<String, String> properties = new HashMap<>(); properties.put("key", generateString(size, 'x')); log.setProperties(properties); try { persistence.putLog(log, "test-p1", PERSISTENCE_NORMAL);
@Override public void read(JSONObject object) throws JSONException { super.read(object); setId(UUID.fromString(object.getString(ID))); if (object.has(EXCEPTION)) { JSONObject jException = object.getJSONObject(EXCEPTION); Exception exception = new Exception(); exception.read(jException); setException(exception); } }
@Override @SuppressWarnings("SimplifiableIfStatement") public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; if (!super.equals(o)) return false; HandledErrorLog errorLog = (HandledErrorLog) o; if (id != null ? !id.equals(errorLog.id) : errorLog.id != null) return false; return exception != null ? exception.equals(errorLog.exception) : errorLog.exception == null; }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + (id != null ? id.hashCode() : 0); result = 31 * result + (exception != null ? exception.hashCode() : 0); return result; } }
log.setProperties(properties); persistence.putLog(log, "test-p1", PERSISTENCE_NORMAL); fail("putLog was expected to fail");
log.setProperties(properties); long id = persistence.putLog(log, "test-p1", PERSISTENCE_NORMAL);
Map<String, String> properties = new HashMap<>(); properties.put("key", generateString(size, 'x')); log.setProperties(properties); try { persistence.putLog(log, "test-p1", PERSISTENCE_NORMAL);
Map<String, String> properties = new HashMap<>(); properties.put("key", generateString(size, 'x')); log.setProperties(properties); try { persistence.putLog(log, "test-p1", PERSISTENCE_NORMAL);
Map<String, String> properties = new HashMap<>(); properties.put("key", generateString(size, 'x')); log.setProperties(properties); try { persistence.putLog(log, "test-p1", PERSISTENCE_CRITICAL);