Skip to content

Commit

Permalink
fix serdes test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
thoniTUB committed Aug 7, 2024
1 parent 09190ae commit d4fc041
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.bakdata.conquery.io.cps.CPSType;
import com.bakdata.conquery.models.identifiable.ids.specific.DatasetId;
import org.jetbrains.annotations.TestOnly;

@CPSType(id = "DATASET", base = StringPermissionBuilder.class)
public class DatasetPermission extends StringPermissionBuilder {
Expand Down Expand Up @@ -38,7 +39,7 @@ public static ConqueryPermission onInstance(Set<Ability> abilities, DatasetId in
return INSTANCE.instancePermission(abilities, instance);
}

@Deprecated
@TestOnly
public static ConqueryPermission onInstance(Ability ability, DatasetId instance) {
return INSTANCE.instancePermission(ability, instance);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.bakdata.conquery.io.cps.CPSType;
import com.bakdata.conquery.models.identifiable.ids.specific.ManagedExecutionId;
import org.jetbrains.annotations.TestOnly;

@CPSType(id = "EXECUTION", base = StringPermissionBuilder.class)
public class ExecutionPermission extends StringPermissionBuilder {
Expand Down Expand Up @@ -43,7 +44,7 @@ public Set<Ability> getAllowedAbilities() {
}

//// Helper functions
@Deprecated
@TestOnly
public static ConqueryPermission onInstance(Ability ability, ManagedExecutionId instance) {
return INSTANCE.instancePermission(ability, instance);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.bakdata.conquery.io.jackson.Jackson;
import com.bakdata.conquery.io.jackson.View;
import com.bakdata.conquery.io.storage.MetaStorage;
import com.bakdata.conquery.io.storage.WorkerStorage;
import com.bakdata.conquery.mode.InternalObjectMapperCreator;
import com.bakdata.conquery.mode.cluster.ClusterNamespaceHandler;
import com.bakdata.conquery.mode.cluster.ClusterState;
Expand All @@ -22,23 +23,29 @@
import com.bakdata.conquery.models.worker.DistributedNamespace;
import com.bakdata.conquery.models.worker.Namespace;
import com.bakdata.conquery.util.NonPersistentStoreFactory;
import com.bakdata.conquery.util.extensions.WorkerStorageExtension;
import com.codahale.metrics.SharedMetricRegistries;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.dropwizard.jersey.validation.Validators;
import lombok.Getter;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.RegisterExtension;

@Getter
public abstract class AbstractSerializationTest {

@RegisterExtension
private static final WorkerStorageExtension WORKER_STORAGE_EXTENSION = new WorkerStorageExtension();

private final Validator validator = Validators.newValidator();
private final ConqueryConfig config = new ConqueryConfig() {{
this.setStorage(new NonPersistentStoreFactory());
}};
private DatasetRegistry<DistributedNamespace> datasetRegistry;
private Namespace namespace;
private MetaStorage metaStorage;
private WorkerStorage workerStorage;


private ObjectMapper managerMetaInternalMapper;
Expand All @@ -57,7 +64,7 @@ public static void beforeAll() {

@BeforeEach
public void before() throws IOException {

workerStorage = WORKER_STORAGE_EXTENSION.getStorage();
metaStorage = new MetaStorage(new NonPersistentStoreFactory());
InternalObjectMapperCreator creator = new InternalObjectMapperCreator(config, metaStorage, validator);
final IndexService indexService = new IndexService(config.getCsv().createCsvParserSettings(), "emptyDefaultLabel");
Expand All @@ -66,6 +73,7 @@ public void before() throws IOException {
creator.init(datasetRegistry);

namespace = datasetRegistry.createNamespace(new Dataset("serialization_test"), metaStorage);
workerStorage.updateDataset(namespace.getDataset());

// Prepare manager meta internal mapper
managerMetaInternalMapper = creator.createInternalObjectMapper(View.Persistence.Manager.class);
Expand All @@ -83,6 +91,7 @@ public void before() throws IOException {

when(shardNode.createInternalObjectMapper(any())).thenCallRealMethod();
shardInternalMapper = shardNode.createInternalObjectMapper(View.Persistence.Shard.class);
getWorkerStorage().injectInto(shardInternalMapper);

// Prepare api mapper with a Namespace injected (usually done by PathParamInjector)
apiMapper = Jackson.copyMapperAndInjectables(Jackson.MAPPER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public void table() throws JSONException, IOException {

SerializationTestUtil
.forType(Table.class)
.objectMappers(getManagerMetaInternalMapper(), getShardInternalMapper(), getApiMapper())
.objectMappers(getNamespaceInternalMapper(), getShardInternalMapper(), getApiMapper())
.registry(registry)
.test(table);
}
Expand Down

0 comments on commit d4fc041

Please sign in to comment.