Variation { public Variation() { this.mId = EMPTY_VARIATION; this.mName = ""; mServeObject = new JSONObject(); mWeight = 0.0; } Variation();  Variation(JSONObject variation); int getId(); String getName(); JSONObject getServeObject(); double getWeight(); @Nullable Object getKey(String key); boolean hasKey(String key); JSONObject getVariationAsJsonObject(); static final int EMPTY_VARIATION; static final String JSON_CONTENT; static final String ID; static final String WEIGHT; static final String NAME; }
@Test public void variationTest() throws JSONException, IOException { String variationData = TestUtils.readJsonFile(getClass(), "com/vwo/mobile/models/variation.json"); Variation variation = new Variation(new JSONObject(variationData)); Assert.assertEquals(variation.getId(), 2); Assert.assertTrue(variation.hasKey("layout")); Assert.assertTrue(variation.hasKey("socialMedia")); Assert.assertFalse(variation.hasKey("android")); Assert.assertEquals(variation.getKey("layout"), "grid"); Assert.assertEquals(variation.getKey("socialMedia"), true); Assert.assertNull(variation.getKey("android")); }