Search in sources :

Example 31 with SafeDepositBoxV2

use of com.nike.cerberus.domain.SafeDepositBoxV2 in project cerberus by Nike-Inc.

the class SafeDepositBoxControllerV2Test method testCreateSafeDepositBox.

@Test
public void testCreateSafeDepositBox() {
    SafeDepositBoxV2 safeDepositBoxV2 = Mockito.mock(SafeDepositBoxV2.class);
    Mockito.when(safeDepositBoxV2.getId()).thenReturn("id");
    Authentication authentication = Mockito.mock(Authentication.class);
    Mockito.when(authentication.getName()).thenReturn("name");
    Mockito.when(safeDepositBoxService.createSafeDepositBoxV2(safeDepositBoxV2, "name")).thenReturn(safeDepositBoxV2);
    UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.newInstance();
    ResponseEntity<SafeDepositBoxV2> safeDepositBoxResponseEntity = safeDepositBoxControllerV2.createSafeDepositBox(safeDepositBoxV2, authentication, uriComponentsBuilder);
    Assert.assertSame(safeDepositBoxV2, safeDepositBoxResponseEntity.getBody());
    HttpHeaders headers = safeDepositBoxResponseEntity.getHeaders();
    Assert.assertEquals("/V2/safe-deposit-box/id", headers.get("Location").get(0));
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) SafeDepositBoxV2(com.nike.cerberus.domain.SafeDepositBoxV2) Authentication(org.springframework.security.core.Authentication) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) Test(org.junit.Test)

Aggregations

SafeDepositBoxV2 (com.nike.cerberus.domain.SafeDepositBoxV2)31 Test (org.junit.Test)29 UserGroupPermission (com.nike.cerberus.domain.UserGroupPermission)15 HashSet (java.util.HashSet)15 CerberusPrincipal (com.nike.cerberus.security.CerberusPrincipal)7 IamPrincipalPermission (com.nike.cerberus.domain.IamPrincipalPermission)6 SafeDepositBoxV1 (com.nike.cerberus.domain.SafeDepositBoxV1)6 OffsetDateTime (java.time.OffsetDateTime)3 IamRolePermission (com.nike.cerberus.domain.IamRolePermission)2 SDBMetadata (com.nike.cerberus.domain.SDBMetadata)2 SafeDepositBoxRecord (com.nike.cerberus.record.SafeDepositBoxRecord)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Role (com.nike.cerberus.domain.Role)1 InputStream (java.io.InputStream)1 HashMap (java.util.HashMap)1 HttpHeaders (org.springframework.http.HttpHeaders)1 Authentication (org.springframework.security.core.Authentication)1 UriComponentsBuilder (org.springframework.web.util.UriComponentsBuilder)1