Search in sources :

Example 1 with DevelopmentAuthorizationConfig

use of com.bakdata.conquery.models.config.auth.DevelopmentAuthorizationConfig in project conquery by bakdata.

the class FormConfigTest method setupTestClass.

@BeforeAll
public void setupTestClass() throws Exception {
    datasetId = dataset.getId();
    datasetId1 = dataset1.getId();
    // Mock DatasetRegistry for translation
    namespacesMock = Mockito.mock(DatasetRegistry.class);
    doAnswer(invocation -> {
        throw new UnsupportedOperationException("Not yet implemented");
    }).when(namespacesMock).getOptional(any());
    doAnswer(invocation -> {
        final DatasetId id = invocation.getArgument(0);
        Namespace namespaceMock = Mockito.mock(Namespace.class);
        if (id.equals(datasetId)) {
            when(namespaceMock.getDataset()).thenReturn(dataset);
        } else if (id.equals(datasetId1)) {
            when(namespaceMock.getDataset()).thenReturn(dataset1);
        } else {
            throw new IllegalStateException("Unkown dataset id.");
        }
        return namespaceMock;
    }).when(namespacesMock).get(any(DatasetId.class));
    when(namespacesMock.getAllDatasets()).thenReturn(List.of(dataset, dataset1));
    when(namespacesMock.injectIntoNew(any(ObjectMapper.class))).thenCallRealMethod();
    when(namespacesMock.inject(any(MutableInjectableValues.class))).thenCallRealMethod();
    storage = new NonPersistentStoreFactory().createMetaStorage();
    ((MutableInjectableValues) FormConfigProcessor.getMAPPER().getInjectableValues()).add(IdResolveContext.class, namespacesMock);
    processor = new FormConfigProcessor(validator, storage, namespacesMock);
    controller = new AuthorizationController(storage, new DevelopmentAuthorizationConfig());
    controller.start();
}
Also used : AuthorizationController(com.bakdata.conquery.models.auth.AuthorizationController) DevelopmentAuthorizationConfig(com.bakdata.conquery.models.config.auth.DevelopmentAuthorizationConfig) FormConfigProcessor(com.bakdata.conquery.models.forms.frontendconfiguration.FormConfigProcessor) MutableInjectableValues(com.bakdata.conquery.io.jackson.MutableInjectableValues) DatasetRegistry(com.bakdata.conquery.models.worker.DatasetRegistry) NonPersistentStoreFactory(com.bakdata.conquery.util.NonPersistentStoreFactory) Namespace(com.bakdata.conquery.models.worker.Namespace) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DatasetId(com.bakdata.conquery.models.identifiable.ids.specific.DatasetId) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

MutableInjectableValues (com.bakdata.conquery.io.jackson.MutableInjectableValues)1 AuthorizationController (com.bakdata.conquery.models.auth.AuthorizationController)1 DevelopmentAuthorizationConfig (com.bakdata.conquery.models.config.auth.DevelopmentAuthorizationConfig)1 FormConfigProcessor (com.bakdata.conquery.models.forms.frontendconfiguration.FormConfigProcessor)1 DatasetId (com.bakdata.conquery.models.identifiable.ids.specific.DatasetId)1 DatasetRegistry (com.bakdata.conquery.models.worker.DatasetRegistry)1 Namespace (com.bakdata.conquery.models.worker.Namespace)1 NonPersistentStoreFactory (com.bakdata.conquery.util.NonPersistentStoreFactory)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1