use of ddf.security.SubjectOperations in project ddf by codice.
the class HistorianTest method setup.
@Before
public void setup() {
historian = new Historian();
uuidGenerator = mock(UuidGenerator.class);
when(uuidGenerator.generateUuid()).thenReturn(UUID.randomUUID().toString());
historian.setUuidGenerator(uuidGenerator);
catalogProvider = mock(CatalogProvider.class);
historian.setCatalogProviders(Collections.singletonList(catalogProvider));
storageProvider = new InMemoryStorageProvider();
historian.setStorageProviders(Collections.singletonList(storageProvider));
historian.setMetacardTypes(Collections.singletonList(MetacardImpl.BASIC_METACARD));
SubjectIdentity subjectIdentity = mock(SubjectIdentity.class);
when(subjectIdentity.getUniqueIdentifier(any())).thenReturn("test");
historian.setSubjectIdentity(subjectIdentity);
SubjectOperations subjectOperations = mock(SubjectOperations.class);
when(subjectOperations.getEmailAddress(any(Subject.class))).thenReturn("test@test.com");
when(subjectOperations.getName(any(Subject.class))).thenReturn("test");
historian.setSubjectOperations(subjectOperations);
historian.setSecurityLogger(mock(SecurityLogger.class));
Security security = mock(Security.class);
Subject subject = mock(MockSubject.class);
when(subject.execute(any(Callable.class))).thenCallRealMethod();
when(security.runAsAdmin(any(PrivilegedAction.class))).thenReturn(subject);
historian.setSecurity(security);
}
Aggregations