Search in sources :

Example 1 with Subject

use of structural.proxy.style1.Subject in project act-platform by mnemonic-no.

the class SubjectInfoServiceAccountResolverTest method testResolveCachesSubject.

@Test
public void testResolveCachesSubject() throws Exception {
    Subject model = Subject.builder().setId(UUID.randomUUID()).build();
    when(subjectResolver.resolveSubject(notNull(), isA(UUID.class))).thenReturn(model);
    resolver.apply(model.getId());
    assertEquals(1, subjectCache.size());
    assertSame(model, subjectCache.get(model.getId()));
}
Also used : UUID(java.util.UUID) Subject(no.mnemonic.act.platform.api.model.v1.Subject) Test(org.junit.Test)

Example 2 with Subject

use of structural.proxy.style1.Subject in project act-platform by mnemonic-no.

the class SubjectInfoServiceAccountResolverTest method testResolvePreviouslyCachedSubject.

@Test
public void testResolvePreviouslyCachedSubject() {
    Subject model = Subject.builder().setId(UUID.randomUUID()).setName("name").build();
    subjectCache.put(model.getId(), model);
    SubjectInfoSEB seb = resolver.apply(model.getId());
    assertNotNull(seb);
    assertEquals(model.getId(), seb.getId());
    assertEquals(model.getName(), seb.getName());
    verifyNoInteractions(subjectResolver);
}
Also used : SubjectInfoSEB(no.mnemonic.act.platform.seb.model.v1.SubjectInfoSEB) Subject(no.mnemonic.act.platform.api.model.v1.Subject) Test(org.junit.Test)

Example 3 with Subject

use of structural.proxy.style1.Subject in project act-platform by mnemonic-no.

the class SubjectByIdResponseResolverTest method testConvertUncachedSubjectNotAvailable.

@Test
public void testConvertUncachedSubjectNotAvailable() throws Exception {
    UUID id = UUID.randomUUID();
    Subject model = converter.apply(id);
    assertNotNull(model);
    assertEquals(id, model.getId());
    assertEquals("N/A", model.getName());
    verify(subjectResolver).resolveSubject(notNull(), eq(id));
}
Also used : UUID(java.util.UUID) Subject(no.mnemonic.act.platform.api.model.v1.Subject) Test(org.junit.Test)

Example 4 with Subject

use of structural.proxy.style1.Subject in project act-platform by mnemonic-no.

the class SubjectByIdResponseResolverTest method testConvertUncachedSubjectWithInvalidCredentials.

@Test
public void testConvertUncachedSubjectWithInvalidCredentials() throws Exception {
    UUID id = UUID.randomUUID();
    when(subjectResolver.resolveSubject(notNull(), isA(UUID.class))).thenThrow(InvalidCredentialsException.class);
    Subject model = converter.apply(id);
    assertNotNull(model);
    assertEquals(id, model.getId());
    assertEquals("N/A", model.getName());
    verify(subjectResolver).resolveSubject(notNull(), eq(id));
}
Also used : UUID(java.util.UUID) Subject(no.mnemonic.act.platform.api.model.v1.Subject) Test(org.junit.Test)

Example 5 with Subject

use of structural.proxy.style1.Subject in project act-platform by mnemonic-no.

the class SubjectByIdResponseResolverTest method testConvertUncachedSubject.

@Test
public void testConvertUncachedSubject() throws Exception {
    UUID id = UUID.randomUUID();
    Subject model = Subject.builder().build();
    when(subjectResolver.resolveSubject(notNull(), isA(UUID.class))).thenReturn(model);
    assertSame(model, converter.apply(id));
    verify(subjectResolver).resolveSubject(notNull(), eq(id));
}
Also used : UUID(java.util.UUID) Subject(no.mnemonic.act.platform.api.model.v1.Subject) Test(org.junit.Test)

Aggregations

Subject (no.mnemonic.act.platform.api.model.v1.Subject)23 Test (org.junit.Test)20 UUID (java.util.UUID)12 OriginEntity (no.mnemonic.act.platform.dao.cassandra.entity.OriginEntity)6 InvalidArgumentException (no.mnemonic.act.platform.api.exceptions.InvalidArgumentException)4 Organization (no.mnemonic.act.platform.api.model.v1.Organization)4 SubjectSPI (no.mnemonic.act.platform.auth.SubjectSPI)3 OriginManager (no.mnemonic.act.platform.dao.cassandra.OriginManager)3 InvalidCredentialsException (no.mnemonic.services.common.auth.InvalidCredentialsException)3 Credentials (no.mnemonic.services.common.auth.model.Credentials)3 Assert (org.junit.Assert)3 Before (org.junit.Before)3 Mock (org.mockito.Mock)3 Mockito (org.mockito.Mockito)3 MockitoAnnotations.initMocks (org.mockito.MockitoAnnotations.initMocks)3 Clock (java.time.Clock)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Optional (java.util.Optional)2 AuthenticationFailedException (no.mnemonic.act.platform.api.exceptions.AuthenticationFailedException)2