Search in sources :

Example 1 with Job

use of example.Job in project elide by yahoo.

the class PersistentResourceTest method testCreateMappedIdObjectSuccess.

@Test()
public void testCreateMappedIdObjectSuccess() {
    final Job job = new Job();
    job.setTitle("day job");
    job.setParent(newParent(1));
    final RequestScope goodScope = buildRequestScope(tx, new TestUser("1"));
    when(tx.createNewObject(ClassType.of(Job.class), goodScope)).thenReturn(job);
    PersistentResource<Job> created = PersistentResource.createObject(ClassType.of(Job.class), goodScope, Optional.empty());
    created.getRequestScope().getPermissionExecutor().executeCommitChecks();
    assertEquals("day job", created.getObject().getTitle(), "The create function should return the requested job object");
    assertNull(created.getObject().getJobId(), "The create function should not override the ID");
    created = PersistentResource.createObject(ClassType.of(Job.class), goodScope, Optional.of("1234"));
    created.getRequestScope().getPermissionExecutor().executeCommitChecks();
    assertEquals("day job", created.getObject().getTitle(), "The create function should return the requested job object");
    assertNull(created.getObject().getJobId(), "The create function should not override the ID");
}
Also used : Job(example.Job) PatchRequestScope(com.yahoo.elide.jsonapi.extensions.PatchRequestScope) TestUser(com.yahoo.elide.core.security.TestUser) Test(org.junit.jupiter.api.Test)

Aggregations

TestUser (com.yahoo.elide.core.security.TestUser)1 PatchRequestScope (com.yahoo.elide.jsonapi.extensions.PatchRequestScope)1 Job (example.Job)1 Test (org.junit.jupiter.api.Test)1