@KOTest public void loadAndParseJSON() throws InterruptedException { if (js == null) { url = Utils.prepareURL( JSONTest.class, "{'firstName': 'Sitar', 'sex': 'MALE'}", "application/json" ); js = Models.bind(new JSONik(), newContext()); js.applyBindings(); js.setFetched(null); js.fetch(url); } Person p = js.getFetched(); if (p == null) { throw new InterruptedException(); } assert "Sitar".equals(p.getFirstName()) : "Expecting Sitar: " + p.getFirstName(); assert Sex.MALE.equals(p.getSex()) : "Expecting MALE: " + p.getSex(); }
@KOTest public void loadAndParseJSONArraySingle() throws InterruptedException { if (js == null) { url = Utils.prepareURL( JSONTest.class, "[{'firstName': 'Gitar', 'sex': 'FEMALE'}]", "application/json" ); js = Models.bind(new JSONik(), newContext()); js.applyBindings(); js.setFetched(null); js.fetch(url); } Person p = js.getFetched(); if (p == null) { throw new InterruptedException(); } assert "Gitar".equals(p.getFirstName()) : "Expecting Gitar: " + p.getFirstName(); assert Sex.FEMALE.equals(p.getSex()) : "Expecting FEMALE: " + p.getSex(); }
@KOTest public void loadAndParseJSONArraySingle() throws InterruptedException { if (js == null) { url = Utils.prepareURL( JSONTest.class, "[{'firstName': 'Gitar', 'sex': 'FEMALE'}]", "application/json" ); js = Models.bind(new JSONik(), newContext()); js.applyBindings(); js.setFetched(null); js.fetch(url); } Person p = js.getFetched(); if (p == null) { throw new InterruptedException(); } assertEquals("Gitar", p.getFirstName(), "Expecting Gitar: " + p.getFirstName()); assertEquals(Sex.FEMALE, p.getSex(), "Expecting FEMALE: " + p.getSex()); }
@KOTest public void loadAndParseJSON() throws InterruptedException { if (js == null) { url = Utils.prepareURL( JSONTest.class, "{'firstName': 'Sitar', 'sex': 'MALE'}", "application/json" ); js = Models.bind(new JSONik(), ctx = newContext()); js.applyBindings(); js.setFetched(null); js.fetch(url); } Person p = js.getFetched(); if (p == null) { throw new InterruptedException(); } assertEquals("Sitar", p.getFirstName(), "Expecting Sitar: " + p.getFirstName()); assertEquals(Sex.MALE, p.getSex(), "Expecting MALE: " + p.getSex()); assertEquals(ctx, onCallback, "Context is the same"); }