Search in sources :

Example 6 with FormConfig

use of com.bakdata.conquery.models.forms.configs.FormConfig in project conquery by bakdata.

the class FormConfigTest method getConfig.

@Test
public void getConfig() {
    // PREPARE
    user.addPermission(dataset.createPermission(Ability.READ.asSet()));
    ObjectMapper mapper = FormConfigProcessor.getMAPPER();
    JsonNode values = mapper.valueToTree(form);
    FormConfig formConfig = new FormConfig(form.getClass().getAnnotation(CPSType.class).id(), values);
    formConfig.setDataset(dataset);
    formConfig.setOwner(user);
    user.addPermission(formConfig.createPermission(Ability.READ.asSet()));
    storage.addFormConfig(formConfig);
    // EXECUTE
    FormConfigFullRepresentation response = processor.getConfig(user, formConfig);
    // CHECK
    assertThat(response).usingRecursiveComparison().ignoringFields(FormConfigOverviewRepresentation.Fields.createdAt).isEqualTo(FormConfigFullRepresentation.builder().formType(form.getClass().getAnnotation(CPSType.class).id()).id(formConfig.getId()).label(formConfig.getLabel()).own(true).ownerName(user.getLabel()).shared(false).groups(Collections.emptySet()).system(false).tags(formConfig.getTags()).values(values).build());
}
Also used : FormConfig(com.bakdata.conquery.models.forms.configs.FormConfig) JsonNode(com.fasterxml.jackson.databind.JsonNode) FormConfigFullRepresentation(com.bakdata.conquery.models.forms.configs.FormConfig.FormConfigFullRepresentation) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) CPSType(com.bakdata.conquery.io.cps.CPSType) Test(org.junit.jupiter.api.Test)

Aggregations

FormConfig (com.bakdata.conquery.models.forms.configs.FormConfig)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 Test (org.junit.jupiter.api.Test)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 FormConfigAPI (com.bakdata.conquery.apiv1.forms.FormConfigAPI)1 AbsoluteMode (com.bakdata.conquery.apiv1.forms.export_form.AbsoluteMode)1 ExportForm (com.bakdata.conquery.apiv1.forms.export_form.ExportForm)1 CQConcept (com.bakdata.conquery.apiv1.query.concept.specific.CQConcept)1 CPSType (com.bakdata.conquery.io.cps.CPSType)1 Group (com.bakdata.conquery.models.auth.entities.Group)1 Dataset (com.bakdata.conquery.models.datasets.Dataset)1 FormConfigFullRepresentation (com.bakdata.conquery.models.forms.configs.FormConfig.FormConfigFullRepresentation)1 CentralRegistry (com.bakdata.conquery.models.identifiable.CentralRegistry)1 IdMapSerialisationTest (com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)1 FormConfigId (com.bakdata.conquery.models.identifiable.ids.specific.FormConfigId)1 Namespace (com.bakdata.conquery.models.worker.Namespace)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 TextNode (com.fasterxml.jackson.databind.node.TextNode)1