AbstractLog implements Log { @Override public void read(JSONObject object) throws JSONException { if (!object.getString(TYPE).equals(getType())) { throw new JSONException("Invalid type"); } setTimestamp(JSONDateUtils.toDate(object.getString(TIMESTAMP))); if (object.has(SID)) { setSid(UUID.fromString(object.getString(SID))); } setDistributionGroupId(object.optString(DISTRIBUTION_GROUP_ID, null)); setUserId(object.optString(USER_ID, null)); if (object.has(DEVICE)) { Device device = new Device(); device.read(object.getJSONObject(DEVICE)); setDevice(device); } }  @Override Date getTimestamp(); @Override void setTimestamp(Date timestamp); @Override UUID getSid(); @Override void setSid(UUID sid); @Override String getDistributionGroupId(); @Override void setDistributionGroupId(String distributionGroupId); @Override String getUserId(); @Override void setUserId(String userId); @Override Device getDevice(); @Override void setDevice(Device device); @Override Object getTag(); @Override void setTag(Object tag); @Override synchronized void addTransmissionTarget(String transmissionTargetToken); @Override synchronized Set<String> getTransmissionTargetTokens(); @Override void write(JSONStringer writer); @Override void read(JSONObject object); @SuppressWarnings("EqualsReplaceableByObjectsCall") @Override boolean equals(Object o); @Override int hashCode();  }
@Test(expected = JSONException.class) public void readDifferentTypeTest() throws JSONException { JSONObject mockJsonObject = mock(JSONObject.class); when(mockJsonObject.getString(CommonProperties.TYPE)).thenReturn("type"); AbstractLog mockLog = new MockLog(); mockLog.read(mockJsonObject); }