@Override public void write(JSONStringer writer) throws JSONException { JSONUtils.write(writer, LIB_VER, getLibVer()); JSONUtils.write(writer, EPOCH, getEpoch()); JSONUtils.write(writer, SEQ, getSeq()); JSONUtils.write(writer, INSTALL_ID, getInstallId()); }
@Override public void read(JSONObject object) throws JSONException { setLibVer(object.optString(LIB_VER, null)); setEpoch(object.optString(EPOCH, null)); setSeq(JSONUtils.readLong(object, SEQ)); if (object.has(INSTALL_ID)) { setInstallId(UUID.fromString(object.getString(INSTALL_ID))); } }
sdk.setEpoch(epochAndSeq.epoch); sdk.setSeq(++epochAndSeq.seq); sdk.setInstallId(mInstallId);
log1.setIKey("t1"); Extensions ext1 = new Extensions(); ext1.setSdk(new SdkExtension()); log1.setExt(ext1); log2.setIKey("t1"); Extensions ext2 = new Extensions(); ext2.setSdk(new SdkExtension()); log2.setExt(ext2); assertNotNull(log1.getExt().getSdk().getEpoch()); assertEquals(log1.getExt().getSdk().getEpoch(), log2.getExt().getSdk().getEpoch()); assertEquals(Long.valueOf(1), log1.getExt().getSdk().getSeq()); assertEquals(Long.valueOf(2), log2.getExt().getSdk().getSeq()); assertEquals(installId, log1.getExt().getSdk().getInstallId()); assertEquals(installId, log2.getExt().getSdk().getInstallId()); log3.setIKey("t2"); Extensions ext3 = new Extensions(); ext3.setSdk(new SdkExtension()); log3.setExt(ext3); when(logSerializer.toCommonSchemaLog(any(Log.class))).thenReturn(Collections.singletonList(log3)); listener.onPreparedLog(originalLog, TEST_GROUP, PERSISTENCE_CRITICAL); assertEquals(Long.valueOf(PERSISTENCE_CRITICAL), log3.getFlags()); assertEquals(Long.valueOf(1), log3.getExt().getSdk().getSeq()); assertNotNull(log3.getExt().getSdk().getEpoch()); assertNotEquals(log1.getExt().getSdk().getEpoch(), log3.getExt().getSdk().getEpoch());
dest.getExt().setSdk(new SdkExtension()); dest.getExt().getSdk().setLibVer(device.getSdkName() + "-" + device.getSdkVersion());
SdkExtension sdk = new SdkExtension(); sdk.setSeq(1L); a.setSdk(sdk); checkNotEquals(a, b); b.setSdk(new SdkExtension()); checkNotEquals(a, b); b.setSdk(a.getSdk());
SdkExtension sdk = new SdkExtension(); sdk.read(object.getJSONObject(SDK)); setSdk(sdk);
@Test public void compareDifferentType() { TestUtils.compareSelfNullClass(new SdkExtension()); }
assertEquals("carrierName", commonSchemaLog.getExt().getNet().getProvider()); assertNotNull(commonSchemaLog.getExt().getSdk()); assertEquals("appcenter.android-1.5.0", commonSchemaLog.getExt().getSdk().getLibVer()); assertNotNull(commonSchemaLog.getExt().getLoc()); assertEquals(commonSchemaTimeZoneOffset, commonSchemaLog.getExt().getLoc().getTz());
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Extensions that = (Extensions) o; if (metadata != null ? !metadata.equals(that.metadata) : that.metadata != null) return false; if (protocol != null ? !protocol.equals(that.protocol) : that.protocol != null) return false; if (user != null ? !user.equals(that.user) : that.user != null) return false; if (device != null ? !device.equals(that.device) : that.device != null) return false; if (os != null ? !os.equals(that.os) : that.os != null) return false; if (app != null ? !app.equals(that.app) : that.app != null) return false; if (net != null ? !net.equals(that.net) : that.net != null) return false; if (sdk != null ? !sdk.equals(that.sdk) : that.sdk != null) return false; return loc != null ? loc.equals(that.loc) : that.loc == null; }
SdkExtension a = new SdkExtension(); SdkExtension b = new SdkExtension(); checkEquals(a, b); a.setLibVer("a1"); checkNotEquals(a, b); b.setLibVer("b1"); checkNotEquals(a, b); b.setLibVer("a1"); checkEquals(a, b); a.setEpoch("a2"); checkNotEquals(a, b); b.setEpoch("b2"); checkNotEquals(a, b); b.setEpoch("a2"); checkEquals(a, b); a.setSeq(0L); checkNotEquals(a, b); b.setSeq(1L); checkNotEquals(a, b); b.setSeq(0L); checkEquals(a, b); a.setInstallId(UUID.randomUUID()); checkNotEquals(a, b); b.setInstallId(UUID.randomUUID()); checkNotEquals(a, b);
log.getExt().setSdk(new SdkExtension()); checkSerialization(serializer, log); log.getExt().getSdk().setLibVer("appcenter.android-1.6.0"); checkSerialization(serializer, log); log.getExt().getSdk().setEpoch(UUIDUtils.randomUUID().toString()); checkSerialization(serializer, log); log.getExt().getSdk().setSeq(21L); checkSerialization(serializer, log); log.getExt().getSdk().setInstallId(UUIDUtils.randomUUID()); checkSerialization(serializer, log);