19
19
import org .w3 .ldp .testsuite .annotations .SpecTest .METHOD ;
20
20
import org .w3 .ldp .testsuite .annotations .SpecTest .STATUS ;
21
21
import org .w3 .ldp .testsuite .exception .SkipException ;
22
+ import org .w3 .ldp .testsuite .http .HttpMethod ;
22
23
import org .w3 .ldp .testsuite .http .LdpPreferences ;
23
24
import org .w3 .ldp .testsuite .mapper .RdfObjectMapper ;
24
25
import org .w3 .ldp .testsuite .vocab .LDP ;
25
26
26
27
import java .io .IOException ;
27
28
29
+ import static org .hamcrest .Matchers .notNullValue ;
28
30
import static org .testng .Assert .assertTrue ;
29
31
import static org .w3 .ldp .testsuite .http .HttpHeaders .ACCEPT ;
30
32
import static org .w3 .ldp .testsuite .http .HttpHeaders .LINK_REL_TYPE ;
33
+ import static org .w3 .ldp .testsuite .http .HttpHeaders .LOCATION ;
31
34
import static org .w3 .ldp .testsuite .http .HttpHeaders .PREFER ;
32
35
import static org .w3 .ldp .testsuite .http .LdpPreferences .PREFER_MINIMAL_CONTAINER ;
33
36
import static org .w3 .ldp .testsuite .http .MediaTypes .TEXT_TURTLE ;
@@ -154,7 +157,7 @@ public void testContainerHasInsertedContentRelation() {
154
157
155
158
@ Test (
156
159
groups = {MUST },
157
- enabled = false ,
160
+ enabled = true ,
158
161
description = "LDPCs whose ldp:insertedContentRelation triple has an "
159
162
+ "object other than ldp:MemberSubject and that create new "
160
163
+ "resources MUST add a triple to the container whose subject is "
@@ -165,10 +168,48 @@ public void testContainerHasInsertedContentRelation() {
165
168
+ "newly created resource in certain cases." )
166
169
@ SpecTest (
167
170
specRefUri = LdpTestSuite .SPEC_URI + "#ldpic-post-indirectmbrrel" ,
168
- testMethod = METHOD .NOT_IMPLEMENTED ,
171
+ testMethod = METHOD .AUTOMATED ,
169
172
approval = STATUS .WG_PENDING )
170
173
public void testPostResource () {
171
- // TODO: Impl testPostResource
174
+ skipIfMethodNotAllowed (HttpMethod .POST );
175
+
176
+ if ( insertedContentRelationProperty != null ) {
177
+ if ( insertedContentRelationProperty .getURI ().equals (LDP .MemberSubject .stringValue ()) ) {
178
+ throw new SkipException (Thread .currentThread ().getStackTrace ()[1 ].getMethodName (),
179
+ "The indirectContainer's ldp:insertedContentRelation triple has ldp:MemberSubject as the object." ,
180
+ skipLog );
181
+ }
182
+ }
183
+
184
+ Model model = postContent ();
185
+ Response postResponse = buildBaseRequestSpecification ()
186
+ .contentType (TEXT_TURTLE )
187
+ .body (model , new RdfObjectMapper ())
188
+ .expect ()
189
+ .statusCode (HttpStatus .SC_CREATED )
190
+ .header (LOCATION , notNullValue ())
191
+ .when ()
192
+ .post (indirectContainer );
193
+
194
+ String location = postResponse .getHeader (LOCATION );
195
+
196
+ Response getResponse = buildBaseRequestSpecification ()
197
+ .header (ACCEPT , TEXT_TURTLE )
198
+ .header (PREFER , include (LdpPreferences .PREFER_CONTAINMENT ))
199
+ .when ()
200
+ .get (indirectContainer );
201
+ Model containerModel = getResponse .as (Model .class , new RdfObjectMapper (indirectContainer ));
202
+ Resource container = containerModel .getResource (indirectContainer );
203
+ Property contains = ResourceFactory .createProperty (LDP .contains .stringValue ());
204
+
205
+ assertTrue (
206
+ container .hasProperty (contains , containerModel .getResource (location )),
207
+ "The IndirectContainer <"
208
+ + indirectContainer
209
+ + "> didn't create a triple with the containerURI as a subject, ldp:contains as the predicate "
210
+ + "and the resource's newly created URI as the object."
211
+ );
212
+
172
213
}
173
214
174
215
private void setInsertedContentRelation () {
0 commit comments