@@ -0,0 +1,2247 @@
+package de.passau.uni.sec.compose.pdp.servioticy;%0A%0Aimport static org.junit.Assert.*;%0A%0Aimport java.io.IOException;%0Aimport java.util.UUID;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport com.fasterxml.jackson.core.JsonProcessingException;%0Aimport com.fasterxml.jackson.databind.JsonNode;%0Aimport com.fasterxml.jackson.databind.ObjectMapper;%0Aimport com.fasterxml.jackson.databind.node.JsonNodeFactory;%0A%0Aimport de.passau.uni.sec.compose.pdp.servioticy.exception.PDPServioticyException;%0A%0Apublic class PostDataToServiceObjectFromTheOutside %0A%7B%0A%09 private PDP pdp; %0A%09%0A%09 @Before%0A%09 public void setUp()%0A%09 %7B%0A%09%09 pdp = new LocalPDP();%0A%09 %7D%0A%09%0A%09 @Test%0A%09 public  void postDataToSOCallCorrect() throws PDPServioticyException%0A%09 %7B%0A%09%09    /*%0A%09%09     * this.id = so.getId();%0A%09%09this.api_token = so.getApiToken();%0A%09%09this.owner_id = so.getOwner().getId();%0A%09%09this.lastModified = so.getLastModified();%0A%09%09     */%0A%09%09//create ObjectMapper instance%0A%09%09%09try %7B%0A%09%09%09%09String token=UUID.randomUUID().toString();%0A%09%09%09%09JsonNode so_data = buildJsonSoMetadata(token);%0A%09%09%09%09pdp.checkAuthorization(token, so_data, null, null, PDP.operationID.SendDataToServiceObject);%0A%09%09%09%7D catch (JsonProcessingException e) %7B%0A%09%09%09%09// TODO Auto-generated catch block%0A%09%09%09%09e.printStackTrace();%0A%09%09%09%7D catch (IOException e) %7B%0A%09%09%09%09fail();%0A%09%09%09%7D%0A%09        %0A%09%09  %0A%09%09%09%0A%09 %7D%0A%09 private JsonNode buildJsonSoMetadata(String token) throws JsonProcessingException, IOException %7B%0A%09%09     String string = %22%7B%5C%22id%5C%22:%5C%2213412341234123412341324%5C%22, %5C%22api_token%5C%22: %5C%22%22+token+%22%5C%22, %5C%22owner_id%5C%22:%5C%22owner_identifier123123%5C%22%7D%22;%0A%09%09    ObjectMapper mapper = new ObjectMapper();%0A%09%09    JsonNode so_data;%0A%09%09%09so_data = mapper.readTree(string);%0A%09%09%09return so_data;%0A%09%7D%0A%0A%09@Test%0A%09 public  void postDataToSOCallIncorrect() throws PDPServioticyException%0A%09 %7B%0A%09%09%09%0A%09%09    try%7B%0A%09%09    %09String token=UUID.randomUUID().toString();%0A%09%09%09%09JsonNode so_data = buildJsonSoMetadata(%22wrong token%22);%0A%09%09%09%09pdp.checkAuthorization(UUID.randomUUID().toString(), so_data, null, null, PDP.operationID.SendDataToServiceObject);%0A%09%09        fail();%0A%09%09    %7D%0A%09%09    catch (PDPServioticyException e) %0A%09%09%09%7B%0A%09%09%09%09assertTrue(true);%0A%09%09%09%7D catch (JsonProcessingException e) %7B%0A%09%09%09%09// TODO Auto-generated catch block%0A%09%09%09%09e.printStackTrace();%0A%09%09%09%7D catch (IOException e) %7B%0A%09%09%09%09fail();%0A%09%09%09%7D%0A%09%09%09%0A%09 %7D%0A%7D%0A

include source folder