cloud test
Showing
No preview for this file type
No preview for this file type
| ... | ... | @@ -9,7 +9,9 @@ import edu.prlab.tyler.iotgateway.cloud.pojo.device.Icon; |
| import edu.prlab.tyler.iotgateway.cloud.pojo.device.Model; | ||
| import edu.prlab.tyler.iotgateway.cloud.pojo.privacy.PrivacyChoice; | ||
| import edu.prlab.tyler.iotgateway.cloud.pojo.privacy.PrivacyContent; | ||
| import edu.prlab.tyler.iotgateway.cloud.pojo.privacy.PrivacyPolicy; | ||
| import edu.prlab.tyler.iotgateway.cloud.pojo.privacy.PrivacyPolicyReport; | ||
| import edu.prlab.tyler.iotgateway.cloud.pojo.privacy.p3p.*; | ||
| import org.junit.Assert; | ||
| import org.junit.Before; | ||
| import org.junit.Test; | ||
| ... | ... | @@ -76,8 +78,22 @@ public class CloudHttpApiTest { |
| .andExpect(status().isOk()) | ||
| .andReturn(); | ||
| device = mapper.readValue(result.getResponse().getContentAsString(), Device.class); | ||
| System.out.println("The return device = " + device.toString()); | ||
| Assert.assertNotNull(device); | ||
| result = mvc.perform(MockMvcRequestBuilders | ||
| .get("/device") | ||
| .accept(MediaType.APPLICATION_JSON_UTF8)) | ||
| .andDo(print()) | ||
| .andExpect(status().isOk()) | ||
| .andReturn(); | ||
| ArrayList<Device> devices = mapper.readValue(result.getResponse().getContentAsString(), | ||
| new TypeReference<ArrayList<Device>>() { | ||
| }); | ||
| Assert.assertNotNull(devices); | ||
| result = mvc.perform(MockMvcRequestBuilders | ||
| .get("/device/" + device.getId()) | ||
| .accept(MediaType.APPLICATION_JSON_UTF8)) | ||
| ... | ... | @@ -87,15 +103,71 @@ public class CloudHttpApiTest { |
| device = mapper.readValue(result.getResponse().getContentAsString(), Device.class); | ||
| Assert.assertNotNull(device); | ||
| PrivacyPolicy oxygenPrivacyPolicy = PrivacyPolicy.builder() | ||
| .id("abe5ca7b-780e-4857-87e6-014870fe0a32") | ||
| .description("本APP會蒐集使用者周遭溫度作為第三方資料之地區環境分析資料。") | ||
| .collector(Collector.builder() | ||
| .name("AirRadio") | ||
| .email("[email protected]") | ||
| .phone("0987654177") | ||
| .build()) | ||
| .remedies(Arrays.asList(Remedy.builder() | ||
| .type(Remedy.Type.LAW) | ||
| .build())) | ||
| .statements(Arrays.asList(Statement.builder() | ||
| .consequence("a1252c49-4188-4e6d-a32e-66604c664fb9") | ||
| .purposes(Arrays.asList(Purpose.builder() | ||
| .type(Purpose.Type.PSEUDO_ANALYSIS) | ||
| .description("本APP會蒐集使用者周遭溫度作為第三方資料之地區環境分析資料。") | ||
| .build())) | ||
| .data(Arrays.asList(Datum.builder() | ||
| .type(Datum.Type.OTHER_CATEGORY) | ||
| .description("室溫資料") | ||
| .build())) | ||
| .recipients(Arrays.asList(Recipient.builder() | ||
| .entity("AirRadio") | ||
| .type(Recipient.Type.OURS) | ||
| .build())) | ||
| .retention(Retention.STATED_PURPOSE) | ||
| .build(), Statement.builder() | ||
| .consequence("a1252c49-4188-4e6d-a32e-66604c664fb9") | ||
| .purposes(Arrays.asList(Purpose.builder() | ||
| .type(Purpose.Type.PSEUDO_ANALYSIS) | ||
| .description("本APP會蒐集使用者周遭溫度作為第三方資料之地區環境分析資料。") | ||
| .build())) | ||
| .data(Arrays.asList(Datum.builder() | ||
| .type(Datum.Type.OTHER_CATEGORY) | ||
| .description("室溫資料") | ||
| .build())) | ||
| .recipients(Arrays.asList(Recipient.builder() | ||
| .entity("AirRadio") | ||
| .type(Recipient.Type.OURS) | ||
| .build())) | ||
| .retention(Retention.STATED_PURPOSE) | ||
| .build() | ||
| )) | ||
| .build(); | ||
| PrivacyPolicyReport privacyPolicyReport = PrivacyPolicyReport.builder() | ||
| .id("0cfb6be3-6f0f-4e63-85b8-e9c936707c0b") | ||
| .version("1.0") | ||
| .description("本APP會蒐集使用者周遭溫度、濕度及空氣品質作為第三方資料之地區環境分析資料。") | ||
| .device(device) | ||
| .policies(Arrays.asList(oxygenPrivacyPolicy)) | ||
| .build(); | ||
| result = mvc.perform(MockMvcRequestBuilders | ||
| .get("/device") | ||
| .accept(MediaType.APPLICATION_JSON_UTF8)) | ||
| .post("/device/privacy") | ||
| .contentType(MediaType.APPLICATION_JSON_UTF8) | ||
| .accept(MediaType.APPLICATION_JSON_UTF8) | ||
| .content(mapper.writeValueAsString(privacyPolicyReport))) | ||
| .andDo(print()) | ||
| .andExpect(status().isOk()) | ||
| .andReturn(); | ||
| ArrayList<Device> devices = mapper.readValue(result.getResponse().getContentAsString(), | ||
| new TypeReference<ArrayList<Device>>() {}); | ||
| Assert.assertNotNull(devices); | ||
| PrivacyPolicyReport returnPolicy = mapper.readValue(result.getResponse().getContentAsString(), | ||
| PrivacyPolicyReport.class); | ||
| Assert.assertNotNull(returnPolicy); | ||
| result = mvc.perform(MockMvcRequestBuilders | ||
| .get("/device/privacy/" + device.getUdn()) | ||
| ... | ... |
File added
Please register or sign in to comment