Clover icon

Magnolia REST Integration Tests 2.1.5

  1. Project Clover database Tue Jan 28 2020 16:43:22 CET
  2. Package info.magnolia.integrationtests.rest.delivery.jcr.v2

File AssetReferenceResolverTest.java

 

Code metrics

0
11
11
1
157
108
11
1
1
11
1

Classes

Class Line # Actions
AssetReferenceResolverTest 45 11 0% 11 22
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /**
2    * This file Copyright (c) 2018 Magnolia International
3    * Ltd. (http://www.magnolia-cms.com). All rights reserved.
4    *
5    *
6    * This file is dual-licensed under both the Magnolia
7    * Network Agreement and the GNU General Public License.
8    * You may elect to use one or the other of these licenses.
9    *
10    * This file is distributed in the hope that it will be
11    * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
12    * implied warranty of MERCHANTABILITY or FITNESS FOR A
13    * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
14    * Redistribution, except as permitted by whichever of the GPL
15    * or MNA you select, is prohibited.
16    *
17    * 1. For the GPL license (GPL), you can redistribute and/or
18    * modify this file under the terms of the GNU General
19    * Public License, Version 3, as published by the Free Software
20    * Foundation. You should have received a copy of the GNU
21    * General Public License, Version 3 along with this program;
22    * if not, write to the Free Software Foundation, Inc., 51
23    * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24    *
25    * 2. For the Magnolia Network Agreement (MNA), this file
26    * and the accompanying materials are made available under the
27    * terms of the MNA which accompanies this distribution, and
28    * is available at http://www.magnolia-cms.com/mna.html
29    *
30    * Any modifications to this file must keep this entire header
31    * intact.
32    *
33    */
34    package info.magnolia.integrationtests.rest.delivery.jcr.v2;
35   
36    import static io.restassured.RestAssured.given;
37    import static org.hamcrest.CoreMatchers.not;
38    import static org.hamcrest.Matchers.*;
39   
40    import org.junit.Test;
41   
42    import io.restassured.builder.ResponseSpecBuilder;
43    import io.restassured.specification.ResponseSpecification;
44   
 
45    public class AssetReferenceResolverTest extends AbstractJcrDeliveryEndpointTest {
46   
 
47  0 toggle @Test
48    public void assetHasResolved() {
49  0 given().expect()
50    .spec(expandedAssetSpec())
51    .spec(expandedAssetLinkSpec())
52    .spec(expandedAssetMetadataSpec())
53    .when()
54    .get("assetReferenceNonConfigurable/v1/imageAsset");
55    }
56   
 
57  0 toggle @Test
58    public void assetHasExpanded() {
59  0 given().expect()
60    .spec(expandedAssetSpec())
61    .spec(expandedAssetLinkSpec())
62    .spec(expandedAssetMetadataSpec())
63    .when()
64    .get("assetReference/v1/imageAsset")
65    .then()
66    .body(not(hasKey("image.renditions")));
67    }
68   
 
69  0 toggle @Test
70    public void assetDisabledResolving() {
71  0 given().when()
72    .get("assetReferenceDisabledAll/v1/imageAsset")
73    .then()
74    .body("image", equalTo("jcr:d01deefa-dba9-4708-8cfa-604320720253"));
75    }
76   
 
77  0 toggle @Test
78    public void assetHasExpandedWithoutMetadata() {
79  0 given().expect()
80    .spec(expandedAssetSpec())
81    .spec(expandedAssetLinkSpec())
82    .when()
83    .get("assetReferenceDisabledMetadata/v1/imageAsset")
84    .then()
85    .body(not(hasKey("image.metadata")));
86    }
87   
 
88  0 toggle @Test
89    public void assetHasExpandedWithoutDownloadLink() {
90  0 given().expect()
91    .spec(expandedAssetSpec())
92    .spec(expandedAssetMetadataSpec())
93    .when()
94    .get("assetReferenceDisabledLink/v1/imageAsset")
95    .then()
96    .body("", not(hasKey("@link")));
97    }
98   
 
99  0 toggle @Test
100    public void assetDisabledExpandingButIncludesDownloadLink() {
101  0 given().when()
102    .get("assetReferenceDisabledExpand/v1/imageAsset")
103    .then()
104    .body("image", equalTo("/magnoliaTest/dam/jcr:d01deefa-dba9-4708-8cfa-604320720253/flickr-surfer-mandolin-373088839_7da451ccc8_b.jpg"));
105    }
106   
 
107  0 toggle @Test
108    public void assetExpandedWithRenditions() {
109  0 given().expect()
110    .spec(expandedAssetSpec())
111    .spec(expandedAssetRenditionsSpec())
112    .when()
113    .get("assetReferenceIncludeRenditions/v1/imageAsset");
114    }
115   
 
116  0 toggle private ResponseSpecification expandedAssetSpec() {
117  0 return new ResponseSpecBuilder()
118    .expectStatusCode(200)
119    .rootPath("image")
120    .expectBody("@name", equalTo("flickr-surfer-mandolin-373088839_7da451ccc8_b.jpg"))
121    .expectBody("@path", equalTo("/flickr-surfer-mandolin-373088839_7da451ccc8_b/flickr-surfer-mandolin-373088839_7da451ccc8_b.jpg"))
122    .expectBody("@id", equalTo("jcr:d01deefa-dba9-4708-8cfa-604320720253"))
123    .build();
124    }
125   
 
126  0 toggle private ResponseSpecification expandedAssetLinkSpec() {
127  0 return new ResponseSpecBuilder()
128    .expectStatusCode(200)
129    .expectBody("image.@link", equalTo("/magnoliaTest/dam/jcr:d01deefa-dba9-4708-8cfa-604320720253/flickr-surfer-mandolin-373088839_7da451ccc8_b.jpg"))
130    .build();
131    }
132   
 
133  0 toggle private ResponseSpecification expandedAssetMetadataSpec() {
134  0 return new ResponseSpecBuilder()
135    .expectStatusCode(200)
136    .rootPath("image.metadata")
137    .expectBody("fileSize", equalTo("327927"))
138    .expectBody("mimeType", equalTo("image/jpeg"))
139    .expectBody("caption", equalTo("Mandolin"))
140    .expectBody("fileSize", equalTo("327927"))
141    .expectBody("height", equalTo("681"))
142    .expectBody("width", equalTo("1024"))
143    .expectBody("format", equalTo("image/jpeg"))
144    .expectBody("rights", equalTo("by-sa/2.0/"))
145    .build();
146    }
147   
 
148  0 toggle private ResponseSpecification expandedAssetRenditionsSpec() {
149  0 return new ResponseSpecBuilder()
150    .expectStatusCode(200)
151    .rootPath("image.renditions")
152    .expectBody("1600.link", equalTo("/magnoliaTest/.imaging/mte/fallback/1600/dam/flickr-surfer-mandolin-373088839_7da451ccc8_b/flickr-surfer-mandolin-373088839_7da451ccc8_b.jpg/jcr:content/flickr-surfer-mandolin-373088839_7da451ccc8_b.jpg"))
153    .expectBody("1600x1200.link", equalTo("/magnoliaTest/.imaging/mte/fallback/1600x1200/dam/flickr-surfer-mandolin-373088839_7da451ccc8_b/flickr-surfer-mandolin-373088839_7da451ccc8_b.jpg/jcr:content/flickr-surfer-mandolin-373088839_7da451ccc8_b.jpg"))
154    .expectBody("nonExisting.link", equalTo("/magnoliaTest/.imaging/default/dam/flickr-surfer-mandolin-373088839_7da451ccc8_b/flickr-surfer-mandolin-373088839_7da451ccc8_b.jpg/jcr:content.jpg"))
155    .build();
156    }
157    }