Search in sources :

Example 1 with OperationsClient

use of io.crnk.operations.client.OperationsClient in project crnk-framework by crnk-project.

the class OperationsExceptionTest method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    operationsClient = new OperationsClient(client);
}
Also used : OperationsClient(io.crnk.operations.client.OperationsClient) Before(org.junit.Before)

Example 2 with OperationsClient

use of io.crnk.operations.client.OperationsClient in project crnk-framework by crnk-project.

the class OperationsPostTest method testMultiplePost.

@Test
public void testMultiplePost() {
    ResourceRepositoryV2<PersonEntity, UUID> personRepo = client.getRepositoryForType(PersonEntity.class);
    PersonEntity person1 = newPerson("1");
    PersonEntity person2 = newPerson("2");
    MovieEntity movie = newMovie("test");
    movie.setDirectors(new HashSet<>(Arrays.asList(person1, person2)));
    // tag::client[]
    OperationsClient operationsClient = new OperationsClient(client);
    OperationsCall call = operationsClient.createCall();
    call.add(HttpMethod.POST, movie);
    call.add(HttpMethod.POST, person1);
    call.add(HttpMethod.POST, person2);
    call.execute();
    // end::client[]
    QuerySpec querySpec = new QuerySpec(PersonEntity.class);
    ResourceList<PersonEntity> persons = personRepo.findAll(querySpec);
    Assert.assertEquals(2, persons.size());
    querySpec = new QuerySpec(MovieEntity.class);
    querySpec.includeRelation(Arrays.asList("directors"));
    ResourceList<MovieEntity> movies = movieRepo.findAll(querySpec);
    Assert.assertEquals(1, movies.size());
    movie = movies.get(0);
    Assert.assertEquals(2, movie.getDirectors().size());
}
Also used : MovieEntity(io.crnk.operations.model.MovieEntity) OperationsClient(io.crnk.operations.client.OperationsClient) OperationsCall(io.crnk.operations.client.OperationsCall) PersonEntity(io.crnk.operations.model.PersonEntity) UUID(java.util.UUID) QuerySpec(io.crnk.core.queryspec.QuerySpec) Test(org.junit.Test)

Example 3 with OperationsClient

use of io.crnk.operations.client.OperationsClient in project crnk-framework by crnk-project.

the class OperationsDeleteRelationTest method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    movieRepo = client.getRepositoryForType(MovieEntity.class);
    operationsClient = new OperationsClient(client);
}
Also used : MovieEntity(io.crnk.operations.model.MovieEntity) OperationsClient(io.crnk.operations.client.OperationsClient) Before(org.junit.Before)

Example 4 with OperationsClient

use of io.crnk.operations.client.OperationsClient in project crnk-framework by crnk-project.

the class OperationsSingleEntityTest method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    movieRepo = client.getRepositoryForType(MovieEntity.class);
    operationsClient = new OperationsClient(client);
}
Also used : MovieEntity(io.crnk.operations.model.MovieEntity) OperationsClient(io.crnk.operations.client.OperationsClient) Before(org.junit.Before)

Aggregations

OperationsClient (io.crnk.operations.client.OperationsClient)4 MovieEntity (io.crnk.operations.model.MovieEntity)3 Before (org.junit.Before)3 QuerySpec (io.crnk.core.queryspec.QuerySpec)1 OperationsCall (io.crnk.operations.client.OperationsCall)1 PersonEntity (io.crnk.operations.model.PersonEntity)1 UUID (java.util.UUID)1 Test (org.junit.Test)1