package com.mumux.androidtesting.actions; import org.json.JSONException; import org.json.JSONObject; import org.junit.Assert; import org.junit.Test; import org.skyscreamer.jsonassert.JSONAssert; public class ActionTest { @Test public void testToString() throws ActionParseException { Action action = ActionParser.getAction("PLANE"); Assert.assertNotNull(action); action.parseValues("on"); Assert.assertEquals("PLANE on", action.toString()); action.setOptional(true); Assert.assertEquals("(PLANE on)", action.toString()); } @Test public void testToJson() throws JSONException { Action action = ActionParser.getAction("PLANE"); Assert.assertNotNull(action); JSONObject jsonObject = action.toJson(); Assert.assertEquals("SYSTEM", jsonObject.getString("category")); Assert.assertEquals("PLANE", jsonObject.getString("name")); JSONAssert.assertEquals("[{\"name\":\"status\",\"value\":false,\"type\":\"ON_OFF\"}]", jsonObject.getJSONArray("arguments").toString(), false); } }