Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Result testApis() {
- List<String> testResults = new ArrayList<>();
- DynamicForm countForm = formfactory.form().bindFromRequest();
- Result index = index();
- String indexOk = String.valueOf(index.status());
- Result carers = carers();
- String carersOk = String.valueOf(carers.status());
- Result doctors = doctors();
- String doctorsOk = String.valueOf(doctors.status());
- Result singlePatient = singlePatient("marydoyle@gmail.com");
- String singlePatientOk = String.valueOf(singlePatient.status());
- Result singleCarer = singleCarer("jimsmith@gmail.com");
- String singleCarerOk = String.valueOf(singleCarer.status());
- Result singleDoctor = singleDoctor("ciaranmaher@gmail.com");
- String singleDoctorOk = String.valueOf(singleDoctor.status());
- Result getCalenderEvents = getCalenderEvents("marydoyle@gmail.com");
- String calenderEventsOk = String.valueOf(getCalenderEvents.status());
- Result getCarerLogs = getCarerLogs("marydoyle@gmail.com");
- String carerLogsOk = String.valueOf(getCarerLogs.status());
- Result getMedLogs = getMedLogs("marydoyle@gmail.com");
- String medLogsOk = String.valueOf(getMedLogs.status());
- Result getCarerTasks = getCarerTasks("marydoyle@gmail.com");
- String carerTasksOk = String.valueOf(getCarerTasks.status());
- testResults.add("index:" + indexOk);
- testResults.add("carers:" + carersOk);
- testResults.add("doctors:" + doctorsOk);
- testResults.add("singlePatient:" + singlePatientOk);
- testResults.add("singleCarer:" + singleCarerOk);
- testResults.add("singleDoctor:" + singleDoctorOk);
- testResults.add("getCalenderEvents:" + calenderEventsOk);
- testResults.add("getCarerLogs:" + carerLogsOk);
- testResults.add("getMedLogs:" + medLogsOk);
- testResults.add("getCarerTasks:" + carerTasksOk);
- try {
- //URL addCalenderEvent = new URL("http://localhost:9000/users/calenderEvents/add?acorn_id=1&allevents={\"events\":[{\"id\":\"1fc5pp9m64aipgf1vph2oqlp0k\",\"title\":\"test\",\"date\":1517961600000,\"location\":\"test\",\"description\":\"test\"}]}");
- URL createCarerLog = new URL("http://localhost:9000/users/carerLogs/create?acorn_id=1&companion_id=1&author=test&log=test");
- URL createMedicationLog = new URL("http://localhost:9000/users/medicationLogs/create?acorn_id=1&companion_id=1&author=test&log=test");
- URL createCarerTask = new URL("http://localhost:9000/users/carerTasks/create?acorn_id=1&companion_id=1&title=test&task=test");
- //HttpURLConnection connection1 = (HttpURLConnection) addCalenderEvent.openConnection();
- HttpURLConnection connection2 = (HttpURLConnection) createCarerLog.openConnection();
- HttpURLConnection connection3 = (HttpURLConnection) createMedicationLog.openConnection();
- HttpURLConnection connection4 = (HttpURLConnection) createCarerTask.openConnection();
- //connection1.setRequestMethod("GET");
- //connection1.connect();
- //String addCalenderEventOk = String.valueOf(connection1.getResponseCode());
- connection2.setRequestMethod("GET");
- connection2.connect();
- String createCarerLogOk = String.valueOf(connection2.getResponseCode());
- connection3.setRequestMethod("GET");
- connection3.connect();
- String createMedicationLogOk = String.valueOf(connection3.getResponseCode());
- connection4.setRequestMethod("GET");
- connection4.connect();
- String createCarerTaskOk = String.valueOf(connection4.getResponseCode());
- // testResults.add("addCalenderEvent:"+addCalenderEventOk);
- testResults.add("createCarerLog:"+createCarerLogOk);
- testResults.add("createMedicationLog:"+createMedicationLogOk);
- testResults.add("createCarerTask:"+createCarerTaskOk);
- //Events event = Events.eventsFinder.query().where().eq("title","test").findUnique();
- // Ebean.delete(event);
- List<CarerLogs> logs = CarerLogs.logFinder.query().where().eq("author","test").findList();
- List<MedicationLogs> medlogs = MedicationLogs.logFinder.query().where().eq("author","test").findList();
- List<CarerTasks> tasks = CarerTasks.taskFinder.query().where().eq("title","test").findList();
- for(CarerLogs carerLog: logs) {
- URL updateCarerLog = new URL("http://localhost:9000/users/carerLogs/update?carer_log_id=" + String.valueOf(carerLog.getCarer_log_id()));
- HttpURLConnection connection6 = (HttpURLConnection) updateCarerLog.openConnection();
- connection6.setRequestMethod("GET");
- connection6.connect();
- String updateCarerLogOk = String.valueOf(connection6.getResponseCode());
- testResults.add("updateCarerLog:"+updateCarerLogOk);
- URL deleteCarerLog = new URL("http://localhost:9000/users/carerLogs/delete?carer_log_id="+String.valueOf(carerLog.getCarer_log_id()));
- HttpURLConnection connection10 = (HttpURLConnection) deleteCarerLog.openConnection();
- connection10.setRequestMethod("GET");
- connection10.connect();
- String deleteCarerLogOk = String.valueOf(connection10.getResponseCode());
- testResults.add("deleteCarerLog:"+deleteCarerLogOk);
- }
- for(MedicationLogs medLog: medlogs) {
- URL updateMedicationLog = new URL("http://localhost:9000/users/medicationLogs/update?med_log_id=" + String.valueOf(medLog.getMed_log_id()));
- HttpURLConnection connection7 = (HttpURLConnection) updateMedicationLog.openConnection();
- connection7.setRequestMethod("GET");
- connection7.connect();
- String updateMedicationLogOk = String.valueOf(connection7.getResponseCode());
- testResults.add("updateMedicationLog:"+updateMedicationLogOk);
- URL deleteMedicationLog = new URL("http://localhost:9000/users/medicationLogs/delete?med_log_id="+String.valueOf(medLog.getMed_log_id()));
- HttpURLConnection connection11 = (HttpURLConnection) deleteMedicationLog.openConnection();
- connection11.setRequestMethod("GET");
- connection11.connect();
- String deleteMedicationLogOk = String.valueOf(connection11.getResponseCode());
- testResults.add("deleteMedicationLog:"+deleteMedicationLogOk);
- }
- for(CarerTasks carerTask: tasks) {
- URL updateCarerTask = new URL("http://localhost:9000/users/carerTasks/update?task_id=" + String.valueOf(carerTask.getTask_id()));
- HttpURLConnection connection8 = (HttpURLConnection) updateCarerTask.openConnection();
- connection8.setRequestMethod("GET");
- connection8.connect();
- String updateCarerTaskOk = String.valueOf(connection8.getResponseCode());
- testResults.add("updateCarerTask:"+updateCarerTaskOk);
- URL deleteCarerTask = new URL("http://localhost:9000/users/carerTasks/delete?task_id="+String.valueOf(carerTask.getTask_id()));
- HttpURLConnection connection12 = (HttpURLConnection) deleteCarerTask.openConnection();
- connection12.setRequestMethod("GET");
- connection12.connect();
- String deleteCarerTaskOk = String.valueOf(connection12.getResponseCode());
- testResults.add("deleteCarerTask:"+deleteCarerTaskOk);
- }
- } catch (MalformedURLException e) {
- e.printStackTrace();
- } catch (ProtocolException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return ok(testApis.render(testResults));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement