public static void createDoctorListByAdmin() throws JsonProcessingException { // speciality.setId(2); // doctor.setSpeciality(speciality); ObjectMapper mapper = new ObjectMapper(); RestTemplate restTemplate = new RestTemplate(); HttpHeaders headers = new HttpHeaders(); headers.set("auth-token", StaticStrings.ADMIN_AUTH_TOKEN); List<Integer> ids = new ArrayList<>(); ids.add(17); ids.add(18); doctor.setInstitutionIds(ids); doctor2.setInstitutionIds(ids); List<Doctor> list = new ArrayList<>(); list.add(doctor); list.add(doctor2); HttpEntity entity = new HttpEntity(list, headers); // System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(entity.getBody())); HttpEntity<Response> response = restTemplate.exchange( StaticStrings.CREATE_DOCTOR_LIST_URI, HttpMethod.POST, entity, Response.class); mapper = new ObjectMapper(); System.out.println( mapper.writerWithDefaultPrettyPrinter().writeValueAsString(entity.getBody())); System.out.println( mapper.writerWithDefaultPrettyPrinter().writeValueAsString(response.getBody())); }
public static void updateDoctorByAdmin(int id) throws JsonProcessingException { doctor.setId(id); doctor.setName("Valera"); speciality.setId(1); doctor.setSpeciality(speciality); RestTemplate restTemplate = new RestTemplate(); HttpHeaders headers = new HttpHeaders(); headers.set("auth-token", StaticStrings.ADMIN_AUTH_TOKEN); HttpEntity entity = new HttpEntity(doctor, headers); HttpEntity<Response> response = restTemplate.exchange( StaticStrings.UPDATE_DOCTOR_URI, HttpMethod.POST, entity, Response.class); ObjectMapper mapper = new ObjectMapper(); System.out.println( mapper.writerWithDefaultPrettyPrinter().writeValueAsString(response.getBody())); }