Skip to content

Commit 1640395

Browse files
Merge pull request #138 from TanyaEf/master
Updated AttributeService, UserService and OrganizationService
2 parents 580fd1d + a9283ff commit 1640395

File tree

68 files changed

+3469
-4137
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+3469
-4137
lines changed

README.md

Lines changed: 256 additions & 181 deletions
Large diffs are not rendered by default.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<dependency>
4444
<groupId>com.jaspersoft.jasperserver</groupId>
4545
<artifactId>jasperserver-dto</artifactId>
46-
<version>6.0.1</version>
46+
<version>6.1.0</version>
4747
</dependency>
4848

4949
<!-- Jersey-->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.attributes;
2+
3+
import com.jaspersoft.jasperserver.dto.authority.ClientUserAttribute;
4+
import com.jaspersoft.jasperserver.dto.authority.hypermedia.HypermediaAttribute;
5+
import com.jaspersoft.jasperserver.dto.authority.hypermedia.HypermediaAttributesListWrapper;
6+
import com.jaspersoft.jasperserver.jaxrs.client.RestClientTestUtil;
7+
import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.NullEntityOperationResult;
8+
import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult;
9+
import java.util.List;
10+
import javax.ws.rs.core.Response;
11+
import org.testng.annotations.AfterClass;
12+
import org.testng.annotations.BeforeClass;
13+
import org.testng.annotations.Test;
14+
15+
import static java.util.Arrays.asList;
16+
import static org.hamcrest.core.IsInstanceOf.instanceOf;
17+
import static org.junit.Assert.assertTrue;
18+
import static org.testng.AssertJUnit.assertEquals;
19+
import static org.testng.AssertJUnit.assertNotNull;
20+
21+
public class OrganizationBatchAttributesServiceIT extends RestClientTestUtil {
22+
23+
private HypermediaAttributesListWrapper serverAttributes;
24+
private String orgName;
25+
26+
@BeforeClass
27+
public void before() {
28+
serverAttributes = new HypermediaAttributesListWrapper();
29+
serverAttributes.setProfileAttributes(asList(
30+
new HypermediaAttribute(new ClientUserAttribute().setName("test_max_threads").setValue("512")),
31+
new HypermediaAttribute(new ClientUserAttribute().setName("test_admin_cell_phone").setValue("03"))));
32+
orgName = "myOrg1";
33+
initClient();
34+
initSession();
35+
}
36+
37+
@Test
38+
public void should_create_attributes() {
39+
40+
OperationResult<HypermediaAttributesListWrapper> attributes = session
41+
.attributesService()
42+
.forOrganization(orgName)
43+
.attributes(asList(serverAttributes.getProfileAttributes().get(0).getName(),
44+
serverAttributes.getProfileAttributes().get(1).getName()))
45+
.createOrUpdate(serverAttributes);
46+
47+
assertNotNull(attributes);
48+
49+
}
50+
51+
@Test(dependsOnMethods = "should_create_attributes")
52+
public void should_return_server_attributes() {
53+
List<HypermediaAttribute> attributes = session
54+
.attributesService()
55+
.forOrganization(orgName)
56+
.allAttributes()
57+
.get()
58+
.getEntity()
59+
.getProfileAttributes();
60+
61+
assertTrue(attributes.size() >= 2);
62+
}
63+
64+
@Test(dependsOnMethods = "should_create_attributes")
65+
public void should_return_server_attributes_with_permissions() {
66+
List<HypermediaAttribute> attributes = session
67+
.attributesService()
68+
.forOrganization(orgName)
69+
.allAttributes()
70+
.setIncludePermissions(true)
71+
.get()
72+
.getEntity()
73+
.getProfileAttributes();
74+
75+
assertTrue(attributes.size() >= 2);
76+
assertTrue(attributes.get(0).getEmbedded() != null);
77+
}
78+
79+
@Test(dependsOnMethods = "should_return_server_attributes_with_permissions")
80+
public void should_return_specified_server_attributes() {
81+
List<HypermediaAttribute> attributes = session
82+
.attributesService()
83+
.forOrganization(orgName)
84+
.attributes(asList(serverAttributes.getProfileAttributes().get(0).getName(),
85+
serverAttributes.getProfileAttributes().get(1).getName()))
86+
.get()
87+
.getEntity()
88+
.getProfileAttributes();
89+
90+
assertTrue(attributes.size() >= 2);
91+
}
92+
93+
94+
95+
@Test(dependsOnMethods = "should_return_specified_server_attributes")
96+
public void should_return_specified_server_attributes_with_permissions() {
97+
List<HypermediaAttribute> attributes = session
98+
.attributesService()
99+
.forOrganization(orgName)
100+
.attributes(asList(serverAttributes.getProfileAttributes().get(0).getName(),
101+
serverAttributes.getProfileAttributes().get(1).getName()))
102+
.setIncludePermissions(true)
103+
.get()
104+
.getEntity()
105+
.getProfileAttributes();
106+
107+
assertTrue(attributes.size() >= 2);
108+
assertTrue(attributes.get(0).getEmbedded() != null);
109+
}
110+
111+
@Test(dependsOnMethods = "should_return_specified_server_attributes_with_permissions")
112+
public void should_delete_specified_server_attributes() {
113+
OperationResult<HypermediaAttributesListWrapper> operationResult = session
114+
.attributesService()
115+
.forOrganization(orgName)
116+
.attributes(asList(serverAttributes.getProfileAttributes().get(0).getName(),
117+
serverAttributes.getProfileAttributes().get(1).getName()))
118+
.delete();
119+
120+
assertTrue(instanceOf(NullEntityOperationResult.class).matches(operationResult));
121+
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), operationResult.getResponse().getStatus());
122+
}
123+
124+
125+
@AfterClass
126+
public void after() {
127+
session.logout();
128+
session = null;
129+
}
130+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.attributes;
2+
3+
import com.jaspersoft.jasperserver.dto.authority.hypermedia.HypermediaAttribute;
4+
import com.jaspersoft.jasperserver.jaxrs.client.RestClientTestUtil;
5+
import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult;
6+
import javax.ws.rs.core.Response;
7+
import org.testng.annotations.AfterClass;
8+
import org.testng.annotations.BeforeClass;
9+
import org.testng.annotations.Test;
10+
11+
import static org.testng.AssertJUnit.assertEquals;
12+
import static org.testng.AssertJUnit.assertNotNull;
13+
import static org.testng.AssertJUnit.assertNull;
14+
15+
16+
public class OrganizationSingleAttributesServiceIT extends RestClientTestUtil {
17+
18+
private HypermediaAttribute attribute;
19+
private String orgName;
20+
21+
@BeforeClass
22+
public void before() {
23+
attribute = new HypermediaAttribute();
24+
attribute.setName("number_of_employees_test");
25+
attribute.setValue("1000+");
26+
orgName = "myOrg1";
27+
initClient();
28+
initSession();
29+
}
30+
31+
@Test
32+
public void should_create_organization_attribute() {
33+
OperationResult<HypermediaAttribute> retrieved = session
34+
.attributesService()
35+
.forOrganization(orgName)
36+
.attribute(attribute.getName())
37+
.createOrUpdate(attribute);
38+
39+
assertNotNull(retrieved);
40+
assertEquals(retrieved.getEntity().getName(), attribute.getName());
41+
42+
}
43+
44+
@Test(dependsOnMethods = "should_create_organization_attribute")
45+
public void should_return_attribute() {
46+
HypermediaAttribute entity = session
47+
.attributesService()
48+
.forOrganization(orgName)
49+
.attribute(attribute.getName())
50+
.get()
51+
.getEntity();
52+
53+
assertEquals(entity.getValue(), attribute.getValue());
54+
assertNull(entity.getEmbedded());
55+
}
56+
57+
@Test(dependsOnMethods = "should_return_attribute")
58+
public void should_return_attribute_with_permissions() {
59+
HypermediaAttribute entity = session
60+
.attributesService()
61+
.forOrganization(orgName)
62+
.attribute(attribute.getName())
63+
.setIncludePermissions(true)
64+
.get()
65+
.getEntity();
66+
67+
assertEquals(entity.getValue(), attribute.getValue());
68+
assertNotNull(entity.getEmbedded());
69+
}
70+
71+
@Test(dependsOnMethods = "should_return_attribute_with_permissions")
72+
public void should_delete_attribute() {
73+
OperationResult<HypermediaAttribute> operationResult = session
74+
.attributesService()
75+
.forOrganization(orgName)
76+
.attribute(attribute.getName())
77+
.delete();
78+
79+
assertNotNull(operationResult);
80+
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), operationResult.getResponse().getStatus());
81+
}
82+
83+
@AfterClass
84+
public void after() {
85+
session.logout();
86+
session = null;
87+
}
88+
}

src/integration-test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/attributes/ServerAttributesServiceIT.java

Lines changed: 0 additions & 124 deletions
This file was deleted.

0 commit comments

Comments
 (0)