use of javax.ws.rs.core.GenericType in project syncope by apache.
the class UserSelfITCase method updateWithoutApproval.
@Test
public void updateWithoutApproval() {
// 1. create user as admin
UserTO created = createUser(UserITCase.getUniqueSampleTO("anonymous@syncope.apache.org")).getEntity();
assertNotNull(created);
assertFalse(created.getUsername().endsWith("XX"));
// 2. self-update (username) - works
UserPatch userPatch = new UserPatch();
userPatch.setKey(created.getKey());
userPatch.setUsername(new StringReplacePatchItem.Builder().value(created.getUsername() + "XX").build());
SyncopeClient authClient = clientFactory.create(created.getUsername(), "password123");
UserTO updated = authClient.getService(UserSelfService.class).update(userPatch).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
assertNotNull(updated);
assertEquals(FlowableDetector.isFlowableEnabledForUsers(syncopeService) ? "active" : "created", updated.getStatus());
assertTrue(updated.getUsername().endsWith("XX"));
}
use of javax.ws.rs.core.GenericType in project syncope by apache.
the class UserSelfITCase method create.
@Test
public void create() {
assumeTrue(FlowableDetector.isFlowableEnabledForUsers(syncopeService));
// 1. self-registration as admin: failure
try {
userSelfService.create(UserITCase.getUniqueSampleTO("anonymous@syncope.apache.org"), true);
fail("This should not happen");
} catch (ForbiddenException e) {
assertNotNull(e);
}
// 2. self-registration as anonymous: works
SyncopeClient anonClient = clientFactory.create();
UserTO self = anonClient.getService(UserSelfService.class).create(UserITCase.getUniqueSampleTO("anonymous@syncope.apache.org"), true).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
assertNotNull(self);
assertEquals("createApproval", self.getStatus());
}
use of javax.ws.rs.core.GenericType in project syncope by apache.
the class UserSelfITCase method delete.
@Test
public void delete() {
UserTO created = createUser(UserITCase.getUniqueSampleTO("anonymous@syncope.apache.org")).getEntity();
assertNotNull(created);
SyncopeClient authClient = clientFactory.create(created.getUsername(), "password123");
UserTO deleted = authClient.getService(UserSelfService.class).delete().readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
assertNotNull(deleted);
assertEquals(FlowableDetector.isFlowableEnabledForUsers(syncopeService) ? "deleteApproval" : null, deleted.getStatus());
}
use of javax.ws.rs.core.GenericType in project kafka-streams-examples by confluentinc.
the class OrdersServiceTest method shouldGetOrderByIdWhenOnDifferentHost.
@Test
public void shouldGetOrderByIdWhenOnDifferentHost() {
OrderBean order = new OrderBean(id(1L), 4L, OrderState.VALIDATED, Product.JUMPERS, 10, 100d);
final Client client = ClientBuilder.newClient();
// Given two rest servers on different ports
rest = new OrdersService("localhost");
rest.start(CLUSTER.bootstrapServers());
Paths paths1 = new Paths("localhost", rest.port());
rest2 = new OrdersService("localhost");
rest2.start(CLUSTER.bootstrapServers());
Paths paths2 = new Paths("localhost", rest2.port());
// And one order
client.target(paths1.urlPost()).request(APPLICATION_JSON_TYPE).post(Entity.json(order));
// When GET to rest1
OrderBean returnedOrder = client.target(paths1.urlGet(order.getId())).queryParam("timeout", MIN / 2).request(APPLICATION_JSON_TYPE).get(new GenericType<OrderBean>() {
});
// Then we should get the order back
assertThat(returnedOrder).isEqualTo(order);
// When GET to rest2
returnedOrder = client.target(paths2.urlGet(order.getId())).queryParam("timeout", MIN / 2).request(APPLICATION_JSON_TYPE).get(new GenericType<OrderBean>() {
});
// Then we should get the order back also
assertThat(returnedOrder).isEqualTo(order);
}
use of javax.ws.rs.core.GenericType in project kafka-streams-examples by confluentinc.
the class OrdersServiceTest method shouldPostOrderAndGetItBack.
@Test
public void shouldPostOrderAndGetItBack() {
OrderBean bean = new OrderBean(id(1L), 2L, OrderState.CREATED, Product.JUMPERS, 10, 100d);
final Client client = ClientBuilder.newClient();
// Given a rest service
rest = new OrdersService("localhost");
rest.start(CLUSTER.bootstrapServers());
Paths paths = new Paths("localhost", rest.port());
// When we POST an order
Response response = client.target(paths.urlPost()).request(APPLICATION_JSON_TYPE).post(Entity.json(bean));
// Then
assertThat(response.getStatus()).isEqualTo(HttpURLConnection.HTTP_CREATED);
// When GET the bean back via it's location
OrderBean returnedBean = client.target(response.getLocation()).queryParam("timeout", MIN / 2).request(APPLICATION_JSON_TYPE).get(new GenericType<OrderBean>() {
});
// Then it should be the bean we PUT
assertThat(returnedBean).isEqualTo(bean);
// When GET the bean back explicitly
returnedBean = client.target(paths.urlGet(1)).queryParam("timeout", MIN / 2).request(APPLICATION_JSON_TYPE).get(new GenericType<OrderBean>() {
});
// Then it should be the bean we PUT
assertThat(returnedBean).isEqualTo(bean);
}
Aggregations