Search in sources :

Example 26 with AnnotationValuePairDefinition

use of org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition in project kie-wb-common by kiegroup.

the class NumericValuePairEditorBaseTest method createEditor.

protected NumericValuePairEditor createEditor(NumberType numberType, String paramName) {
    NumericValuePairEditor numericEditor = new NumericValuePairEditor(singleEditorView);
    AnnotationDefinition annotationDefinition = createAnnotationDefinition(numberType);
    AnnotationValuePairDefinition valuePairDefinition = annotationDefinition.getValuePair(paramName);
    numericEditor.init(valuePairDefinition);
    return numericEditor;
}
Also used : AnnotationDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition) AnnotationValuePairDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition)

Example 27 with AnnotationValuePairDefinition

use of org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition in project kie-wb-common by kiegroup.

the class CharacterValuePairEditorTest method testInvalidValidValueChange.

@Test
public void testInvalidValidValueChange() {
    CharacterValuePairEditor characterEditor = new CharacterValuePairEditor(view);
    AnnotationValuePairDefinition valuePairDefinition = annotationDefinition.getValuePair("charParam1");
    characterEditor.init(valuePairDefinition);
    when(view.getValue()).thenReturn("AFD");
    characterEditor.onValueChange();
    assertFalse(characterEditor.isValid());
}
Also used : AnnotationValuePairDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition) Test(org.junit.Test)

Example 28 with AnnotationValuePairDefinition

use of org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition in project kie-wb-common by kiegroup.

the class CharacterValuePairEditorTest method testValidValueChange.

@Test
public void testValidValueChange() {
    CharacterValuePairEditor characterEditor = new CharacterValuePairEditor(view);
    AnnotationValuePairDefinition valuePairDefinition = annotationDefinition.getValuePair("charParam1");
    characterEditor.init(valuePairDefinition);
    when(view.getValue()).thenReturn("  A   ");
    characterEditor.onValueChange();
    assertTrue(characterEditor.isValid());
    // the editor internally trims the entered string
    assertEquals("A", characterEditor.getValue());
}
Also used : AnnotationValuePairDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition) Test(org.junit.Test)

Example 29 with AnnotationValuePairDefinition

use of org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition in project kie-wb-common by kiegroup.

the class MultipleStringValuePairEditorTest method testEditorLoad.

@Test
public void testEditorLoad() {
    stringEditors.clear();
    List<String> originalValues = new ArrayList<String>();
    originalValues.add("AAA");
    originalValues.add("BBB");
    originalValues.add("CCC");
    MultipleStringValuePairEditor multiStringEditor = new MultipleStringValuePairEditorExtended(multipleEditorView);
    AnnotationValuePairDefinition valuePairDefinition = annotationDefinition.getValuePair("stringParam1");
    multiStringEditor.init(valuePairDefinition);
    verify(multipleEditorView, times(1)).setValuePairLabel(valuePairDefinition.getName());
    verify(multipleEditorView, times(1)).showValuePairRequiredIndicator(false);
    multiStringEditor.setValue(originalValues);
    // three individual editors should have been created.
    assertEquals(3, stringEditors.size());
    // and populated with the corresponding value
    verify(singleEditorView, times(1)).setValue("AAA");
    verify(singleEditorView, times(1)).setValue("BBB");
    verify(singleEditorView, times(1)).setValue("CCC");
    assertTrue(multiStringEditor.isValid());
}
Also used : ArrayList(java.util.ArrayList) AnnotationValuePairDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition) Test(org.junit.Test)

Example 30 with AnnotationValuePairDefinition

use of org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition in project kie-wb-common by kiegroup.

the class StringValuePairEditorTest method testValidValueChange.

@Test
public void testValidValueChange() {
    StringValuePairEditor stringEditor = new StringValuePairEditor(view);
    AnnotationValuePairDefinition valuePairDefinition = annotationDefinition.getValuePair("stringParam1");
    stringEditor.init(valuePairDefinition);
    when(view.getValue()).thenReturn("ABCDE");
    stringEditor.onValueChange();
    assertTrue(stringEditor.isValid());
    assertEquals("ABCDE", stringEditor.getValue());
}
Also used : AnnotationValuePairDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition) Test(org.junit.Test)

Aggregations

AnnotationValuePairDefinition (org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition)33 Test (org.junit.Test)22 ArrayList (java.util.ArrayList)8 AnnotationDefinition (org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition)8 DataObject (org.kie.workbench.common.services.datamodeller.core.DataObject)4 AnnotationImpl (org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl)4 AnnotationSource (org.jboss.forge.roaster.model.source.AnnotationSource)3 DataModelerService (org.kie.workbench.common.screens.datamodeller.service.DataModelerService)3 Annotation (org.kie.workbench.common.services.datamodeller.core.Annotation)3 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Entity (javax.persistence.Entity)1 ValuePair (org.jboss.forge.roaster.model.ValuePair)1 AdvancedAnnotationListEditorView (org.kie.workbench.common.screens.datamodeller.client.widgets.advanceddomain.annotationlisteditor.AdvancedAnnotationListEditorView)1 GenerationTools (org.kie.workbench.common.services.datamodeller.codegen.GenerationTools)1 AnnotationDefinitionRequest (org.kie.workbench.common.services.datamodeller.driver.model.AnnotationDefinitionRequest)1 AnnotationDefinitionResponse (org.kie.workbench.common.services.datamodeller.driver.model.AnnotationDefinitionResponse)1 AnnotationDescr (org.kie.workbench.common.services.datamodeller.parser.descr.AnnotationDescr)1 ElementValueDescr (org.kie.workbench.common.services.datamodeller.parser.descr.ElementValueDescr)1 ElementValuePairDescr (org.kie.workbench.common.services.datamodeller.parser.descr.ElementValuePairDescr)1