@Test(expectedExceptions = JSONConverterException.class) public void testMissingConverter() throws JSONConverterException { Model mo = new DefaultModel(); final Node n0 = mo.newNode(); mo.getMapping().off(n0); final ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo); plan.add(new BootNode(n0, 0, 1)); ReconfigurationPlanConverter rcp = new ReconfigurationPlanConverter(); rcp.toJSON(plan); }
@Override public JSONObject toJSON(ReconfigurationPlan plan) throws JSONConverterException { final JSONObject ob = new JSONObject(); final Model src = plan.getOrigin(); ob.put(ORIGIN_LABEL, mc.toJSON(src)); final JSONArray actions = new JSONArray(); for (final Action a : plan.getActions()) { final ActionConverter ac = java3json.get(a.getClass()); if (ac == null) { throw new JSONConverterException( "No converter registered for '" + a.getClass() + "'"); } final JSONObject json = ac.toJSON(a); eventsToJSON(a, json); actions.add(json); } ob.put(ACTIONS_LABEL, actions); return ob; }
ReconfigurationPlanConverter implements
    JSONObjectConverter<ReconfigurationPlan> { @Override public JSONObject toJSON(ReconfigurationPlan plan) throws JSONConverterException { final JSONObject ob = new JSONObject(); final Model src = plan.getOrigin(); ob.put(ORIGIN_LABEL, mc.toJSON(src)); final JSONArray actions = new JSONArray(); for (final Action a : plan.getActions()) { final ActionConverter ac = java3json.get(a.getClass()); if (ac == null) { throw new JSONConverterException( "No converter registered for '" + a.getClass() + "'"); } final JSONObject json = ac.toJSON(a); eventsToJSON(a, json); actions.add(json); } ob.put(ACTIONS_LABEL, actions); return ob; } }
ReconfigurationPlanConverter implements
    JSONObjectConverter<ReconfigurationPlan> { @Override public JSONObject toJSON(ReconfigurationPlan plan) throws JSONConverterException { final JSONObject ob = new JSONObject(); final Model src = plan.getOrigin(); ob.put(ORIGIN_LABEL, mc.toJSON(src)); final JSONArray actions = new JSONArray(); for (final Action a : plan.getActions()) { final ActionConverter ac = java3json.get(a.getClass()); if (ac == null) { throw new JSONConverterException( "No converter registered for '" + a.getClass() + "'"); } final JSONObject json = ac.toJSON(a); eventsToJSON(a, json); actions.add(json); } ob.put(ACTIONS_LABEL, actions); return ob; } ReconfigurationPlanConverter(ModelConverter c);  ReconfigurationPlanConverter(); }
ReconfigurationPlanConverter implements
    JSONObjectConverter<ReconfigurationPlan> { @Override public JSONObject toJSON(ReconfigurationPlan plan) throws JSONConverterException { final JSONObject ob = new JSONObject(); final Model src = plan.getOrigin(); ob.put(ORIGIN_LABEL, mc.toJSON(src)); final JSONArray actions = new JSONArray(); for (final Action a : plan.getActions()) { final ActionConverter ac = java3json.get(a.getClass()); if (ac == null) { throw new JSONConverterException( "No converter registered for '" + a.getClass() + "'"); } final JSONObject json = ac.toJSON(a); eventsToJSON(a, json); actions.add(json); } ob.put(ACTIONS_LABEL, actions); return ob; } ReconfigurationPlanConverter(ModelConverter c);  ReconfigurationPlanConverter(); @Override ReconfigurationPlan fromJSON(JSONObject ob); ModelConverter getModelConverter(); @Override JSONObject toJSON(ReconfigurationPlan plan); void register(final EventConverter<? extends Event> ec); void register(final ActionConverter<? extends Action> ec); static ReconfigurationPlanConverter newBundle(); }
ReconfigurationPlanConverter implements
    JSONObjectConverter<ReconfigurationPlan> { @Override public JSONObject toJSON(ReconfigurationPlan plan) throws JSONConverterException { final JSONObject ob = new JSONObject(); final Model src = plan.getOrigin(); ob.put(ORIGIN_LABEL, mc.toJSON(src)); final JSONArray actions = new JSONArray(); for (final Action a : plan.getActions()) { final ActionConverter ac = java3json.get(a.getClass()); if (ac == null) { throw new JSONConverterException( "No converter registered for '" + a.getClass() + "'"); } final JSONObject json = ac.toJSON(a); eventsToJSON(a, json); actions.add(json); } ob.put(ACTIONS_LABEL, actions); return ob; } ReconfigurationPlanConverter(ModelConverter c);  ReconfigurationPlanConverter(); @Override ReconfigurationPlan fromJSON(JSONObject ob); ModelConverter getModelConverter(); @Override JSONObject toJSON(ReconfigurationPlan plan); void register(final EventConverter<? extends Event> ec); void register(final ActionConverter<? extends Action> ec); static ReconfigurationPlanConverter newBundle(); static final String ORIGIN_LABEL; static final String ACTIONS_LABEL; static final String HOOK_LABEL; }