UploadDataAction extends ActionSupport implements PrincipalAware { public String upload() { PatientAccount account = patientDao.getByUsername(getUserPrincipal().getName()); PatientData pa = new PatientData(); pa.setDataSource(patientData.getDataSource()); pa.setDataType(patientData.getDataType()); pa.setVersion(patientData.getVersion()); pa.setNotes(patientData.getNotes()); pa.setTags(Arrays.asList(StringUtils.split(getTags(), ","))); pa.setFileName(getDataFileFileName()); try { pa.setFileData(FileUtils.readFileToByteArray(getDataFile())); } catch (IOException e) { LOG.error("Error reading file data.", e); } patientDataService.addPatientData(account.getGuid(), pa); return SUCCESS; } @Inject  UploadDataAction(PatientDataService patientDataService, PatientAccountDao accountDao); @Override @SkipValidation String execute(); String upload(); @SkipValidation String markSurveyTaken(); List<PatientData> getRetrievedPatientData(); void setRetrievedPatientData(List<PatientData> retrievedPatientData); File getDataFile(); void setDataFile(File dataFile); String getDataFileFileName(); void setDataFileFileName(String dataFileFileName); PatientData getPatientData(); void setPatientData(PatientData patientData); String getTags(); void setTags(String tags); PrincipalProxy getPrincipalProxy(); @Override void setPrincipalProxy(PrincipalProxy principalProxy); boolean isSurveyTaken(); void setSurveyTaken(boolean surveyTaken);  }
@Test public void upload() { URL uploadUrl = UploadDataAction.class.getClassLoader().getResource("upload-data.txt"); action.getPatientData().setDataSource(PatientDataSource.HL7); action.getPatientData().setDataType(PatientDataType.GENOME_FULL_SEQUENCE); action.getPatientData().setNotes("Test File Upload"); action.setDataFile(FileUtils.toFile(uploadUrl)); action.setDataFileFileName("upload-data.txt"); action.setTags("ACTION,TAGS"); assertEquals(Action.SUCCESS, action.upload()); }