@Test public void testCreateFromSaveString() throws Exception { Project recreatedProject = (Project) projectSaverLoader.createFromSaveString( projectSaverLoader.createSaveString(project)); ElectionDescription recreatedElectionDescription = recreatedProject.getElecDescr(); assert (recreatedElectionDescription.getName().equals("testDescription")); assert (recreatedElectionDescription.getCode().get(0).equals("sdfgokdffg")); assert (recreatedElectionDescription.getCode().get(1).equals("sdkofgdfg")); assert (recreatedElectionDescription.getVotingDeclLine() == 2); ElectionCheckParameter recreatedElectionCheckParameter = project.getElectionCheckParameter(); assert (recreatedElectionCheckParameter.getAmountCandidates().get(0).equals(1)); assert (recreatedElectionCheckParameter.getAmountCandidates().get(1).equals(2)); assert (recreatedElectionCheckParameter.getAmountSeats().get(0).equals(1)); assert (recreatedElectionCheckParameter.getAmountSeats().get(1).equals(2)); assert (recreatedElectionCheckParameter.getAmountVoters().get(0).equals(1)); assert (recreatedElectionCheckParameter.getAmountVoters().get(1).equals(2)); assert (recreatedElectionCheckParameter.getArgument().equals("-- unwind 6")); assert (recreatedElectionCheckParameter.getProcesses() == 4); TimeOut recreatedTimeOut = recreatedElectionCheckParameter.getTimeout(); assert (recreatedTimeOut.getDuration() == 10800000); assert (recreatedTimeOut.getOrigUnit().equals(TimeUnit.HOURS)); PLModel recreatedPLModel = recreatedProject.getPropList(); assert (recreatedPLModel.getPropertyList().get(0).getDescription().getName().equals("description1")); assert (recreatedPLModel.getPropertyList().get(0).getDescription().getPostConditionsDescription().getCode(). equals("CODECODEOCDEOASD ASDAOSDASOD ;;; ;ASODAOSD")); assert (recreatedPLModel.getPropertyList().get(0).getDescription().getPreConditionsDescription().getCode(). equals("CODECODEOCDEOASD ASDAOSDASOD ;;; ;ASODAOSD")); assert (recreatedPLModel.getPropertyList().get(0).getDescription().getSymbolicVariableList().get(0). getId().equals("voter1")); assert (recreatedPLModel.getPropertyList().get(0).getDescription().getSymbolicVariableList().get(0) .getInternalTypeContainer().getInternalType().equals(InternalTypeRep.VOTER)); assert (recreatedPLModel.getPropertyList().get(0).getDescription().getSymbolicVariableList().get(1) .getId().equals("voter2")); assert (recreatedPLModel.getPropertyList().get(0).getDescription().getSymbolicVariableList().get(1) .getInternalTypeContainer().getInternalType().equals(InternalTypeRep.VOTER)); assert (recreatedPLModel.getPropertyList().get(0).getDescription().getSymbolicVariableList().get(2) .getId().equals("candidate")); assert (recreatedPLModel.getPropertyList().get(0).getDescription().getSymbolicVariableList().get(2) .getInternalTypeContainer().getInternalType().equals(InternalTypeRep.CANDIDATE)); assert (recreatedPLModel.getPropertyList().get(0).getDescription().getSymbolicVariableList().get(3) .getId().equals("seat")); assert (recreatedPLModel.getPropertyList().get(0).getDescription().getSymbolicVariableList().get(3) .getInternalTypeContainer().getInternalType().equals(InternalTypeRep.SEAT)); assert (recreatedPLModel.getPropertyList().get(0).getTestStatus().equals(true)); assert (recreatedPLModel.getPropertyList().get(1).getDescription().getName().equals("description2")); assert (recreatedPLModel.getPropertyList().get(1).getDescription().getPostConditionsDescription().getCode(). equals("CODECODEOCDEOASD ASDAOSDASOD ;;; ;ASODAOSD")); assert (recreatedPLModel.getPropertyList().get(1).getDescription().getPreConditionsDescription().getCode(). equals("CODECODEOCDEOASD ASDAOSDASOD ;;; ;ASODAOSD")); assert (recreatedPLModel.getPropertyList().get(1).getDescription().getSymbolicVariableList().get(0). getId().equals("voter1")); assert (recreatedPLModel.getPropertyList().get(1).getDescription().getSymbolicVariableList().get(0) .getInternalTypeContainer().getInternalType().equals(InternalTypeRep.VOTER)); assert (recreatedPLModel.getPropertyList().get(1).getDescription().getSymbolicVariableList().get(1) .getId().equals("voter2")); assert (recreatedPLModel.getPropertyList().get(1).getDescription().getSymbolicVariableList().get(1) .getInternalTypeContainer().getInternalType().equals(InternalTypeRep.VOTER)); assert (recreatedPLModel.getPropertyList().get(1).getDescription().getSymbolicVariableList().get(2) .getId().equals("candidate")); assert (recreatedPLModel.getPropertyList().get(1).getDescription().getSymbolicVariableList().get(2) .getInternalTypeContainer().getInternalType().equals(InternalTypeRep.CANDIDATE)); assert (recreatedPLModel.getPropertyList().get(1).getDescription().getSymbolicVariableList().get(3) .getId().equals("seat")); assert (recreatedPLModel.getPropertyList().get(1).getDescription().getSymbolicVariableList().get(3) .getInternalTypeContainer().getInternalType().equals(InternalTypeRep.SEAT)); assert (recreatedPLModel.getPropertyList().get(1).getTestStatus().equals(false)); }
@Override public Object createFromSaveString(String s) throws ArrayIndexOutOfBoundsException { Map<String,String> m = new SaverLoaderHelper().parseSaveString(s); String name = m.get("name"); String descStr = m.get("elecDesc"); ElectionDescription electionDescription = (ElectionDescription) electionDescriptionSaverLoader.createFromSaveString(descStr); String propListStr = m.get("propList"); PLModel propertyList = ((PLModel) propertyListSaverLoader.createFromSaveString(propListStr)); String paramStr = m.get("electionCheckParams"); ElectionCheckParameter electionCheckParameter = (ElectionCheckParameter) ElectionCheckParameterSaverLoader.createFromSaveString(paramStr); return new Project(electionCheckParameter, propertyList, electionDescription, name); }
ProjectSaverLoader implements SaverLoader { @Override public Object createFromSaveString(String s) throws ArrayIndexOutOfBoundsException { Map<String,String> m = new SaverLoaderHelper().parseSaveString(s); String name = m.get("name"); String descStr = m.get("elecDesc"); ElectionDescription electionDescription = (ElectionDescription) electionDescriptionSaverLoader.createFromSaveString(descStr); String propListStr = m.get("propList"); PLModel propertyList = ((PLModel) propertyListSaverLoader.createFromSaveString(propListStr)); String paramStr = m.get("electionCheckParams"); ElectionCheckParameter electionCheckParameter = (ElectionCheckParameter) ElectionCheckParameterSaverLoader.createFromSaveString(paramStr); return new Project(electionCheckParameter, propertyList, electionDescription, name); } }
ProjectSaverLoader implements SaverLoader { @Override public Object createFromSaveString(String s) throws ArrayIndexOutOfBoundsException { Map<String,String> m = new SaverLoaderHelper().parseSaveString(s); String name = m.get("name"); String descStr = m.get("elecDesc"); ElectionDescription electionDescription = (ElectionDescription) electionDescriptionSaverLoader.createFromSaveString(descStr); String propListStr = m.get("propList"); PLModel propertyList = ((PLModel) propertyListSaverLoader.createFromSaveString(propListStr)); String paramStr = m.get("electionCheckParams"); ElectionCheckParameter electionCheckParameter = (ElectionCheckParameter) ElectionCheckParameterSaverLoader.createFromSaveString(paramStr); return new Project(electionCheckParameter, propertyList, electionDescription, name); } ProjectSaverLoader(); }
ProjectSaverLoader implements SaverLoader { @Override public Object createFromSaveString(String s) throws ArrayIndexOutOfBoundsException { Map<String,String> m = new SaverLoaderHelper().parseSaveString(s); String name = m.get("name"); String descStr = m.get("elecDesc"); ElectionDescription electionDescription = (ElectionDescription) electionDescriptionSaverLoader.createFromSaveString(descStr); String propListStr = m.get("propList"); PLModel propertyList = ((PLModel) propertyListSaverLoader.createFromSaveString(propListStr)); String paramStr = m.get("electionCheckParams"); ElectionCheckParameter electionCheckParameter = (ElectionCheckParameter) ElectionCheckParameterSaverLoader.createFromSaveString(paramStr); return new Project(electionCheckParameter, propertyList, electionDescription, name); } ProjectSaverLoader(); @Override String createSaveString(Object obj); @Override Object createFromSaveString(String s); }
ProjectSaverLoader implements SaverLoader { @Override public Object createFromSaveString(String s) throws ArrayIndexOutOfBoundsException { Map<String,String> m = new SaverLoaderHelper().parseSaveString(s); String name = m.get("name"); String descStr = m.get("elecDesc"); ElectionDescription electionDescription = (ElectionDescription) electionDescriptionSaverLoader.createFromSaveString(descStr); String propListStr = m.get("propList"); PLModel propertyList = ((PLModel) propertyListSaverLoader.createFromSaveString(propListStr)); String paramStr = m.get("electionCheckParams"); ElectionCheckParameter electionCheckParameter = (ElectionCheckParameter) ElectionCheckParameterSaverLoader.createFromSaveString(paramStr); return new Project(electionCheckParameter, propertyList, electionDescription, name); } ProjectSaverLoader(); @Override String createSaveString(Object obj); @Override Object createFromSaveString(String s);  }