Skip to content

Commit a486cab

Browse files
authored
JCL-340: Pluralize getter names in WebIdProfile class (#449)
1 parent a7bd5cb commit a486cab

File tree

4 files changed

+142
-4
lines changed

4 files changed

+142
-4
lines changed

webid/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@
6262
<version>${slf4j.version}</version>
6363
<scope>test</scope>
6464
</dependency>
65+
<dependency>
66+
<groupId>org.junit.jupiter</groupId>
67+
<artifactId>junit-jupiter-engine</artifactId>
68+
<version>${junit.version}</version>
69+
<scope>test</scope>
70+
</dependency>
6571
</dependencies>
6672

6773
<build>

webid/src/main/java/com/inrupt/client/webid/WebIdProfile.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,35 +66,79 @@ public WebIdProfile(final URI identifier, final Dataset dataset) {
6666
* Retrieve the RDF type values.
6767
*
6868
* @return the {@code rdf:type} values
69+
* @deprecated use the {@link #getTypes} method
6970
*/
71+
@Deprecated
7072
public Set<URI> getType() {
73+
return getTypes();
74+
}
75+
76+
/**
77+
* Retrieve the RDF type values.
78+
*
79+
* @return the {@code rdf:type} values
80+
*/
81+
public Set<URI> getTypes() {
7182
return new Node(rdf.createIRI(getIdentifier().toString()), getGraph()).getType();
7283
}
7384

7485
/**
7586
* Retrieve the list of OIDC issuers.
7687
*
7788
* @return the {@code solid:oidcIssuer} values
89+
* @deprecated use the {@link #getOidcIssuers} method
7890
*/
91+
@Deprecated
7992
public Set<URI> getOidcIssuer() {
93+
return getOidcIssuers();
94+
}
95+
96+
/**
97+
* Retrieve the list of OIDC issuers.
98+
*
99+
* @return the {@code solid:oidcIssuer} values
100+
*/
101+
public Set<URI> getOidcIssuers() {
80102
return new Node(rdf.createIRI(getIdentifier().toString()), getGraph()).getOidcIssuer();
81103
}
82104

83105
/**
84106
* Retrieve the list of related profile resources.
85107
*
86108
* @return the {@code rdfs:seeAlso} values
109+
* @deprecated use the {@link #relatedResources} method
87110
*/
111+
@Deprecated
88112
public Set<URI> getSeeAlso() {
113+
return getRelatedResources();
114+
}
115+
116+
/**
117+
* Retrieve the list of related profile resources.
118+
*
119+
* @return the {@code rdfs:seeAlso} values
120+
*/
121+
public Set<URI> getRelatedResources() {
89122
return new Node(rdf.createIRI(getIdentifier().toString()), getGraph()).getSeeAlso();
90123
}
91124

92125
/**
93126
* Retrieve the list of storage locations.
94127
*
95128
* @return the {@code pim:storage} values
129+
* @deprecated use the {@link #getStorages} method
96130
*/
131+
@Deprecated
97132
public Set<URI> getStorage() {
133+
return getStorages();
134+
}
135+
136+
/**
137+
* Retrieve the list of storage locations.
138+
*
139+
* @return the {@code pim:storage} values
140+
*/
141+
public Set<URI> getStorages() {
98142
return new Node(rdf.createIRI(getIdentifier().toString()), getGraph()).getStorage();
99143
}
100144

webid/src/test/java/com/inrupt/client/webid/WebIdMockHttpService.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
import com.github.tomakehurst.wiremock.WireMockServer;
2626
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
2727

28-
import java.util.Map;
29-
3028
public class WebIdMockHttpService {
3129

3230
private final WireMockServer wireMockServer;
@@ -56,12 +54,12 @@ private void setupMocks() {
5654
);
5755
}
5856

59-
public Map<String, String> start() {
57+
public String start() {
6058
wireMockServer.start();
6159

6260
setupMocks();
6361

64-
return Map.of("webid_uri", wireMockServer.baseUrl());
62+
return wireMockServer.baseUrl();
6563
}
6664

6765
public void stop() {
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* Copyright 2023 Inrupt Inc.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal in
6+
* the Software without restriction, including without limitation the rights to use,
7+
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
8+
* Software, and to permit persons to whom the Software is furnished to do so,
9+
* subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16+
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
18+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*/
21+
package com.inrupt.client.webid;
22+
23+
import static org.junit.jupiter.api.Assertions.*;
24+
25+
import com.inrupt.client.solid.SolidSyncClient;
26+
27+
import java.net.URI;
28+
29+
import org.junit.jupiter.api.AfterAll;
30+
import org.junit.jupiter.api.BeforeAll;
31+
import org.junit.jupiter.api.Test;
32+
33+
class WebIdProfileTest {
34+
35+
private static final URI AGENT = URI.create("http://xmlns.test/foaf/0.1/Agent");
36+
private static final URI SEE_ALSO = URI.create("https://storage.example.test/storage-id/extendedProfile");
37+
private static final URI ISSUER = URI.create("https://login.example.test");
38+
private static final URI STORAGE = URI.create("https://storage.example.test/storage-id/");
39+
40+
private static final WebIdMockHttpService mockHttpServer = new WebIdMockHttpService();
41+
private static final SolidSyncClient client = SolidSyncClient.getClient();
42+
private static String baseUrl;
43+
44+
@BeforeAll
45+
static void setup() {
46+
baseUrl = mockHttpServer.start();
47+
}
48+
49+
@AfterAll
50+
static void teardown() {
51+
mockHttpServer.stop();
52+
}
53+
54+
@Test
55+
void testGetProfileSlash() {
56+
final URI uri = URI.create(baseUrl + "/webId");
57+
try (final WebIdProfile profile = client.read(uri, WebIdProfile.class)) {
58+
assertEquals(uri, profile.getIdentifier());
59+
assertTrue(profile.getTypes().contains(AGENT));
60+
assertTrue(profile.getRelatedResources().contains(SEE_ALSO));
61+
assertTrue(profile.getOidcIssuers().contains(ISSUER));
62+
assertTrue(profile.getStorages().contains(STORAGE));
63+
}
64+
}
65+
66+
@Test
67+
@SuppressWarnings("deprecation")
68+
void testGetProfileSlashDeprecatedMethods() {
69+
final URI uri = URI.create(baseUrl + "/webId");
70+
try (final WebIdProfile profile = client.read(uri, WebIdProfile.class)) {
71+
assertEquals(uri, profile.getIdentifier());
72+
assertTrue(profile.getType().contains(AGENT));
73+
assertTrue(profile.getSeeAlso().contains(SEE_ALSO));
74+
assertTrue(profile.getOidcIssuer().contains(ISSUER));
75+
assertTrue(profile.getStorage().contains(STORAGE));
76+
}
77+
}
78+
79+
@Test
80+
void testGetProfileHash() {
81+
final URI uri = URI.create(baseUrl + "/webIdHash#me");
82+
try (final WebIdProfile profile = client.read(uri, WebIdProfile.class)) {
83+
assertEquals(uri, profile.getIdentifier());
84+
assertTrue(profile.getTypes().contains(AGENT));
85+
assertTrue(profile.getRelatedResources().contains(SEE_ALSO));
86+
assertTrue(profile.getOidcIssuers().contains(ISSUER));
87+
assertTrue(profile.getStorages().contains(STORAGE));
88+
}
89+
}
90+
}

0 commit comments

Comments
 (0)