use of com.bakdata.conquery.io.jackson.MutableInjectableValues 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();
}
use of com.bakdata.conquery.io.jackson.MutableInjectableValues in project conquery by bakdata.
the class SerializationTests method treeConcept.
@Test
public void treeConcept() throws IOException, JSONException {
Dataset dataset = new Dataset();
dataset.setName("datasetName");
TreeConcept concept = new TreeConcept();
concept.setDataset(dataset);
concept.setLabel("conceptLabel");
concept.setName("conceptName");
Table table = new Table();
Column column = new Column();
column.setLabel("colLabel");
column.setName("colName");
column.setType(MajorTypeId.STRING);
column.setTable(table);
Column dateColumn = new Column();
dateColumn.setLabel("colLabel2");
dateColumn.setName("colName2");
dateColumn.setType(MajorTypeId.DATE);
dateColumn.setTable(table);
table.setColumns(new Column[] { column, dateColumn });
table.setDataset(dataset);
table.setLabel("tableLabel");
table.setName("tableName");
column.setTable(table);
ConceptTreeConnector connector = new ConceptTreeConnector();
connector.setConcept(concept);
connector.setLabel("connLabel");
connector.setName("connName");
connector.setColumn(column);
concept.setConnectors(List.of(connector));
ValidityDate valDate = new ValidityDate();
valDate.setColumn(dateColumn);
valDate.setConnector(connector);
valDate.setLabel("valLabel");
valDate.setName("valName");
connector.setValidityDates(List.of(valDate));
CentralRegistry registry = new CentralRegistry();
registry.register(dataset);
registry.register(concept);
registry.register(column);
registry.register(dateColumn);
registry.register(table);
registry.register(connector);
registry.register(valDate);
final Validator validator = Validators.newValidator();
concept.setValidator(validator);
SerializationTestUtil.forType(TreeConcept.class).registry(registry).injectables(new Injectable() {
@Override
public MutableInjectableValues inject(MutableInjectableValues values) {
return values.add(Validator.class, validator);
}
}).test(concept);
}
use of com.bakdata.conquery.io.jackson.MutableInjectableValues in project conquery by bakdata.
the class SerializationTests method table.
@Test
public void table() throws JSONException, IOException {
Dataset dataset = new Dataset();
dataset.setName("datasetName");
Table table = new Table();
Column column = new Column();
column.setLabel("colLabel");
column.setName("colName");
column.setType(MajorTypeId.STRING);
column.setTable(table);
table.setColumns(new Column[] { column });
table.setDataset(dataset);
table.setLabel("tableLabel");
table.setName("tableName");
CentralRegistry registry = new CentralRegistry();
registry.register(dataset);
registry.register(table);
registry.register(column);
final Validator validator = Validators.newValidator();
SerializationTestUtil.forType(Table.class).registry(registry).injectables(new Injectable() {
@Override
public MutableInjectableValues inject(MutableInjectableValues values) {
return values.add(Validator.class, validator);
}
}).test(table);
}
use of com.bakdata.conquery.io.jackson.MutableInjectableValues in project conquery by bakdata.
the class ShardNode method run.
@Override
protected void run(Environment environment, Namespace namespace, ConqueryConfig config) throws Exception {
this.environment = environment;
connector = new NioSocketConnector();
jobManager = new JobManager(getName(), config.isFailOnError());
synchronized (environment) {
environment.lifecycle().manage(this);
validator = environment.getValidator();
scheduler = environment.lifecycle().scheduledExecutorService("Scheduled Messages").build();
}
this.config = config;
config.initialize(this);
scheduler.scheduleAtFixedRate(this::reportJobManagerStatus, 30, 1, TimeUnit.SECONDS);
final ObjectMapper binaryMapper = config.configureObjectMapper(Jackson.copyMapperAndInjectables(Jackson.BINARY_MAPPER));
((MutableInjectableValues) binaryMapper.getInjectableValues()).add(Validator.class, environment.getValidator());
workers = new Workers(getConfig().getQueries().getExecutionPool(), binaryMapper, getConfig().getCluster().getEntityBucketSize());
final Collection<WorkerStorage> workerStorages = config.getStorage().loadWorkerStorages();
for (WorkerStorage workerStorage : workerStorages) {
workers.createWorker(workerStorage, config.isFailOnError());
}
log.info("All Worker Storages loaded: {}", workers.getWorkers().size());
}
use of com.bakdata.conquery.io.jackson.MutableInjectableValues in project conquery by bakdata.
the class SerializationTests method bucketCompoundDateRange.
@Test
public void bucketCompoundDateRange() throws JSONException, IOException {
Dataset dataset = new Dataset();
dataset.setName("datasetName");
Table table = new Table();
Column startCol = new Column();
startCol.setName("startCol");
startCol.setType(MajorTypeId.DATE);
startCol.setTable(table);
Column endCol = new Column();
endCol.setLabel("endLabel");
endCol.setName("endCol");
endCol.setType(MajorTypeId.DATE);
endCol.setTable(table);
Column compoundCol = new Column();
compoundCol.setName("compoundCol");
compoundCol.setType(MajorTypeId.DATE_RANGE);
compoundCol.setTable(table);
table.setColumns(new Column[] { startCol, endCol, compoundCol });
table.setDataset(dataset);
table.setName("tableName");
Import imp = new Import(table);
imp.setName("importTest");
DateRangeTypeCompound compoundStore = new DateRangeTypeCompound(startCol.getName(), endCol.getName(), new BitSetStore(BitSet.valueOf(new byte[] { 0b1000 }), new BitSet(), 4));
// 0b1000 is a binary representation of 8 so that the 4th is set to make sure that BitSet length is 4.
ColumnStore startStore = new IntegerDateStore(new ShortArrayStore(new short[] { 1, 2, 3, 4 }, Short.MIN_VALUE));
ColumnStore endStore = new IntegerDateStore(new ShortArrayStore(new short[] { 5, 6, 7, 8 }, Short.MIN_VALUE));
Bucket bucket = new Bucket(0, 1, 4, new ColumnStore[] { startStore, endStore, compoundStore }, Collections.emptySet(), new int[0], new int[0], imp);
compoundStore.setParent(bucket);
CentralRegistry registry = new CentralRegistry();
registry.register(dataset);
registry.register(startCol);
registry.register(endCol);
registry.register(compoundCol);
registry.register(table);
registry.register(imp);
registry.register(bucket);
final Validator validator = Validators.newValidator();
SerializationTestUtil.forType(Bucket.class).registry(registry).injectables(new Injectable() {
@Override
public MutableInjectableValues inject(MutableInjectableValues values) {
return values.add(Validator.class, validator);
}
}).test(bucket);
}
Aggregations