Search in sources :

Example 1 with UserGrant

use of io.imunity.furms.domain.resource_access.UserGrant in project furms by unity-idm.

the class ResourceAllocationDatabaseRepositoryTest method shouldFindUsersGrants.

@Test
void shouldFindUsersGrants() {
    CorrelationId correlationId = CorrelationId.randomID();
    UserGrantEntity userAllocation = userGrantEntityRepository.save(UserGrantEntity.builder().siteId(siteId).projectId(projectId).projectAllocationId(projectAllocationId).userId("userId").build());
    UserGrantJobEntity userGrantJobEntity = UserGrantJobEntity.builder().userAllocationId(userAllocation.getId()).status(AccessStatus.GRANTED).correlationId(UUID.fromString(correlationId.id)).message("text").build();
    userGrantJobEntityRepository.save(userGrantJobEntity);
    Set<UserGrant> userGrants = resourceAccessDatabaseRepository.findUsersGrantsByProjectId(projectId.toString());
    assertThat(userGrants.size()).isEqualTo(1);
    UserGrant userGrant = userGrants.iterator().next();
    assertThat(userGrant.userId).isEqualTo("userId");
    assertThat(userGrant.projectAllocationId).isEqualTo(projectAllocationId.toString());
    assertThat(userGrant.status).isEqualTo(AccessStatus.GRANTED);
    assertThat(userGrant.errorMessage.get().message).isEqualTo("text");
}
Also used : UserGrant(io.imunity.furms.domain.resource_access.UserGrant) CorrelationId(io.imunity.furms.domain.site_agent.CorrelationId) DBIntegrationTest(io.imunity.furms.db.DBIntegrationTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

DBIntegrationTest (io.imunity.furms.db.DBIntegrationTest)1 UserGrant (io.imunity.furms.domain.resource_access.UserGrant)1 CorrelationId (io.imunity.furms.domain.site_agent.CorrelationId)1 Test (org.junit.jupiter.api.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1