当前位置: 首页>>代码示例>>Java>>正文


Java DataObject.addAnnotation方法代码示例

本文整理汇总了Java中org.kie.workbench.common.services.datamodeller.core.DataObject.addAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java DataObject.addAnnotation方法的具体用法?Java DataObject.addAnnotation怎么用?Java DataObject.addAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.kie.workbench.common.services.datamodeller.core.DataObject的用法示例。


在下文中一共展示了DataObject.addAnnotation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadDataObjectPlanningSolution

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
@Test
public void loadDataObjectPlanningSolution() {
    DataObject dataObject = context.getDataObject();
    dataObject.addAnnotation(DataModelerEditorsTestHelper.createAnnotation(PlanningSolution.class,
                                                                           null,
                                                                           null));

    PlannerDataObjectEditor objectEditor = createObjectEditor();
    objectEditor.onContextChange(context);

    verify(view,
           times(1)).enablePlanningSolutionCheckBox(true);
    verify(view,
           times(1)).showPlanningSolutionHelpIcon(false);

    verify(assetsUsageService,
           never()).getAssetUsages(anyString(),
                                   any(),
                                   any(Path.class));
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:21,代码来源:PlannerDataObjectEditorTest.java

示例2: checkPlanningSolutionOtherExists

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
@Test
public void checkPlanningSolutionOtherExists() {
    DataObject dataObject = new DataObjectImpl("test",
                                               "Test");
    dataObject.addAnnotation(new AnnotationImpl(DriverUtils.buildAnnotationDefinition(PlanningSolution.class)));

    Path dataObjectPath = mock(Path.class);
    Path otherDataObjectPath = mock(Path.class);
    when(assetsUsageService.getAssetUsages(PlanningSolution.class.getName(),
                                           ResourceType.JAVA,
                                           dataObjectPath)).thenReturn(Arrays.asList(otherDataObjectPath));

    Collection<ValidationMessage> result = saveValidator.validate(dataObjectPath,
                                                                  dataObject);
    assertEquals(1,
                 result.size());

    ValidationMessage message = result.iterator().next();
    assertTrue(message instanceof PlanningSolutionToBeDuplicatedMessage);
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:21,代码来源:PlanningSolutionSaveValidatorTest.java

示例3: validateIsAPlanningScore

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
@Test
public void validateIsAPlanningScore() {
    DataObject dataObject = new DataObjectImpl("test",
                                               "PlanningSolution");
    dataObject.addAnnotation(new AnnotationImpl(DriverUtils.buildAnnotationDefinition(PlanningSolution.class)));

    ObjectProperty objectProperty = new ObjectPropertyImpl("score",
                                                           HardSoftScore.class.getName(),
                                                           false);
    objectProperty.addAnnotation(new AnnotationImpl(DriverUtils.buildAnnotationDefinition(PlanningScore.class)));
    objectProperty.addAnnotation(new AnnotationImpl(DriverUtils.buildAnnotationDefinition(Generated.class)));

    Collection<ValidationMessage> result = deleteValidator.validate(dataObject,
                                                                    objectProperty);
    assertEquals(1,
                 result.size());
    assertTrue(result.iterator().next() instanceof PlanningScoreToBeDeletedMessage);
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:19,代码来源:PlanningScoreDeleteValidatorTest.java

示例4: createPlanningSolution

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
private DataObject createPlanningSolution() {
    DataObject dataObject = new DataObjectImpl("test",
                                               "TestSolution");

    AnnotationImpl planningSolutionAnnotation = new AnnotationImpl(DriverUtils.buildAnnotationDefinition(PlanningSolution.class));
    dataObject.addAnnotation(planningSolutionAnnotation);

    ObjectProperty scoreObjectProperty = new ObjectPropertyImpl("score",
                                                                BendableScore.class.getName(),
                                                                false);
    dataObject.addProperty(scoreObjectProperty);

    AnnotationImpl planningScoreAnnotation = new AnnotationImpl(DriverUtils.buildAnnotationDefinition(PlanningScore.class));
    planningScoreAnnotation.setValue("bendableHardLevelsSize",
                                     1);
    planningScoreAnnotation.setValue("bendableSoftLevelsSize",
                                     2);
    scoreObjectProperty.addAnnotation(planningScoreAnnotation);

    return dataObject;
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:22,代码来源:ScoreHolderServiceImplTest.java

示例5: onPersistableDataObjectCreatedTest

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
@Test
public void onPersistableDataObjectCreatedTest() {

    DataModelerEventObserver eventObserver = createObserver();
    PersistenceDescriptorModel descriptorModel = createModel();

    DataObject dataObject = new DataObjectImpl("package1", "PersistableObject");
    dataObject.addAnnotation(new AnnotationImpl(DriverUtils.buildAnnotationDefinition(Entity.class)));

    when(descriptorPath.toURI()).thenReturn(DESCRIPTOR_PATH);
    when(descriptorService.calculatePersistenceDescriptorPath(any(Module.class))).thenReturn(descriptorPath);
    when(descriptorService.load(descriptorPath)).thenReturn(descriptorModel);
    when(ioService.exists(any(org.uberfire.java.nio.file.Path.class))).thenReturn(true);

    DataObjectCreatedEvent createdEvent = new DataObjectCreatedEvent(module, dataObject);
    eventObserver.onDataObjectCreated(createdEvent);

    verify(descriptorService, times(1)).save(eq(descriptorPath), eq(descriptorModel), any(Metadata.class), anyString());
    assertTrue(descriptorModel.getPersistenceUnit().getClasses().contains(dataObject.getClassName()));
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:21,代码来源:DataModelerEventObserverTest.java

示例6: onPersistableDataObjectDeletedTest

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
@Test
public void onPersistableDataObjectDeletedTest() {

    DataModelerEventObserver eventObserver = createObserver();
    PersistenceDescriptorModel descriptorModel = createModel();
    descriptorModel.getPersistenceUnit().getClasses().add("package1.PersistableObject");

    DataObject dataObject = new DataObjectImpl("package1", "PersistableObject");
    dataObject.addAnnotation(new AnnotationImpl(DriverUtils.buildAnnotationDefinition(Entity.class)));

    when(descriptorPath.toURI()).thenReturn(DESCRIPTOR_PATH);
    when(descriptorService.calculatePersistenceDescriptorPath(any(Module.class))).thenReturn(descriptorPath);
    when(descriptorService.load(descriptorPath)).thenReturn(descriptorModel);
    when(ioService.exists(any(org.uberfire.java.nio.file.Path.class))).thenReturn(true);

    DataObjectDeletedEvent deletedEvent = new DataObjectDeletedEvent(module, dataObject);
    eventObserver.onDataObjectDeleted(deletedEvent);

    verify(descriptorService, times(1)).save(eq(descriptorPath), eq(descriptorModel), any(Metadata.class), anyString());
    assertFalse(descriptorModel.getPersistenceUnit().getClasses().contains(dataObject.getClassName()));
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:22,代码来源:DataModelerEventObserverTest.java

示例7: loadDataObjectWithBendableScoreType

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
@Test
public void loadDataObjectWithBendableScoreType() {
    PlannerDataObjectEditor objectEditor = createObjectEditor();

    DataObject dataObject = context.getDataObject();

    dataObject.addAnnotation(DataModelerEditorsTestHelper.createAnnotation(PlanningSolution.class,
                                                                           null,
                                                                           null));

    ObjectProperty scoreObjectProperty = new ObjectPropertyImpl("score",
                                                                BendableScore.class.getName(),
                                                                false);
    dataObject.addProperty(scoreObjectProperty);

    scoreObjectProperty.addAnnotation(DataModelerEditorsTestHelper.createAnnotation(PlanningScore.class,
                                                                                    new Pair("bendableHardLevelsSize",
                                                                                             5),
                                                                                    new Pair("bendableSoftLevelsSize",
                                                                                             10)));
    scoreObjectProperty.addAnnotation(DataModelerEditorsTestHelper.createAnnotation(Generated.class,
                                                                                    null,
                                                                                    null));

    objectEditor.onContextChange(context);

    verify(view,
           times(1)).setPlanningSolutionBendableScoreHardLevelsSize(5);
    verify(view,
           times(1)).setPlanningSolutionBendableScoreSoftLevelsSize(10);
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:32,代码来源:PlannerDataObjectEditorTest.java

示例8: fieldPlanningEntitySettings

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
@Test
public void fieldPlanningEntitySettings() {

    PlannerDataObjectFieldEditor fieldEditor = createFieldEditor();

    //first configure the DataObject as a PlanningEntity
    DataObject dataObject = context.getDataObject();
    dataObject.addAnnotation(new AnnotationImpl(context.getAnnotationDefinition(PlanningEntity.class.getName())));

    ObjectProperty field1 = dataObject.getProperty("field1");
    //emulates the selection of field1
    context.setObjectProperty(field1);

    //The domain editors typically reacts upon DataModelerContext changes.
    //when the context changes the editor will typically be reloaded.
    fieldEditor.onContextChange(context);

    //emulate the user input
    when(view.getPlanningVariableValue()).thenReturn(true);
    when(view.getValueRangeProviderRefsValue()).thenReturn("valueRangeProviderRefsValue");

    fieldEditor.onPlanningVariableChange();
    fieldEditor.onValueRangeProviderRefsChange();

    List<String> valueRangeProviderRefs = new ArrayList<String>();
    valueRangeProviderRefs.add("valueRangeProviderRefsValue");
    assertNotNull(field1.getAnnotation(PlanningVariable.class.getName()));
    assertEquals(valueRangeProviderRefs,
                 field1.getAnnotation(PlanningVariable.class.getName()).getValue("valueRangeProviderRefs"));
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:31,代码来源:PlannerDataObjectFieldEditorTest.java

示例9: planningSolutionSettings

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
@Test
public void planningSolutionSettings() {

    PlannerDataObjectFieldEditor fieldEditor = createFieldEditor();

    //first configure the DataObject as a PlanningSolution
    DataObject dataObject = context.getDataObject();
    dataObject.addAnnotation(new AnnotationImpl(context.getAnnotationDefinition(PlanningSolution.class.getName())));
    dataObject.addProperty("score",
                           HardSoftScore.class.getName());

    ObjectProperty field1 = dataObject.getProperty("field1");
    //emulates the selection of field1
    context.setObjectProperty(field1);

    //The domain editors typically reacts upon DataModelerContext changes.
    //when the context changes the editor will typically be reloaded.
    fieldEditor.onContextChange(context);

    when(view.getValueRangeProviderValue()).thenReturn(true);
    when(view.getValueRangeProviderIdValue()).thenReturn("valueRangeProviderIdValue");

    //emulate the user input
    fieldEditor.onValueRangeProviderChange();
    fieldEditor.onValueRangeProviderIdChange();

    assertNotNull(field1.getAnnotation(ValueRangeProvider.class.getName()));
    assertEquals("valueRangeProviderIdValue",
                 AnnotationValueHandler.getStringValue(field1,
                                                       ValueRangeProvider.class.getName(),
                                                       "id"));
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:33,代码来源:PlannerDataObjectFieldEditorTest.java

示例10: checkPlanningSolutionNoOtherExists

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
@Test
public void checkPlanningSolutionNoOtherExists() {
    DataObject dataObject = new DataObjectImpl("test",
                                               "Test");
    dataObject.addAnnotation(new AnnotationImpl(DriverUtils.buildAnnotationDefinition(PlanningSolution.class)));

    Path dataObjectPath = mock(Path.class);
    when(assetsUsageService.getAssetUsages(PlanningSolution.class.getName(),
                                           ResourceType.JAVA,
                                           dataObjectPath)).thenReturn(Arrays.asList(dataObjectPath));

    Collection<ValidationMessage> result = saveValidator.validate(dataObjectPath,
                                                                  dataObject);
    assertTrue(result.isEmpty());
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:16,代码来源:PlanningSolutionSaveValidatorTest.java

示例11: postProcess

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
@Test
public void postProcess() {
    Path sourcePath = PathFactory.newPath("TestSource.java",
                                          "file:///dataObjects");

    when(ioService.readAllString(Paths.convert(sourcePath))).thenReturn("test source");

    DataObject dataObject = new DataObjectImpl("test",
                                               "TestSource");
    dataObject.addAnnotation(new AnnotationImpl(DriverUtils.buildAnnotationDefinition(PlanningSolution.class)));
    GenerationResult generationResult = new GenerationResult();
    generationResult.setDataObject(dataObject);
    when(dataModelerService.loadDataObject(any(),
                                           anyString(),
                                           any())).thenReturn(generationResult);

    Package _package = mock(Package.class);
    when(_package.getPackageMainResourcesPath()).thenReturn(PathFactory.newPath("dataObjects",
                                                                                "file:///dataObjects"));
    when(kieProjectService.resolvePackage(sourcePath)).thenReturn(_package);

    when(ioService.exists(any())).thenReturn(true);

    deleteHelper.postProcess(sourcePath);

    verify(ioService,
           times(1)).deleteIfExists(any(org.uberfire.java.nio.file.Path.class));
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:29,代码来源:PlanningSolutionDeleteHelperTest.java

示例12: postProcess

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
@Test
public void postProcess() {
    Path sourcePath = PathFactory.newPath("TestSource.java",
                                          "file:///dataObjects");
    Path destinationPath = PathFactory.newPath("TestDestination.java",
                                               "file:///dataObjects");

    when(ioService.readAllString(Paths.convert(sourcePath))).thenReturn("test source");

    DataObject dataObject = new DataObjectImpl("test",
                                               "TestSource");
    dataObject.addAnnotation(new AnnotationImpl(DriverUtils.buildAnnotationDefinition(PlanningSolution.class)));
    GenerationResult generationResult = new GenerationResult();
    generationResult.setDataObject(dataObject);
    when(dataModelerService.loadDataObject(any(),
                                           anyString(),
                                           any())).thenReturn(generationResult);

    Package _package = mock(Package.class);
    when(_package.getPackageMainResourcesPath()).thenReturn(PathFactory.newPath("dataObjects",
                                                                                "file:///dataObjects"));
    when(kieProjectService.resolvePackage(sourcePath)).thenReturn(_package);

    when(ioService.exists(any())).thenReturn(true);

    copyHelper.postProcess(sourcePath,
                           destinationPath);

    verify(ioService,
           times(1)).copy(any(org.uberfire.java.nio.file.Path.class),
                          any(org.uberfire.java.nio.file.Path.class));
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:33,代码来源:PlanningSolutionCopyHelperTest.java

示例13: postProcess

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
@Test
public void postProcess() {
    Path sourcePath = PathFactory.newPath("TestSource.java",
                                          "file:///dataObjects");
    Path destinationPath = PathFactory.newPath("TestDestination.java",
                                               "file:///dataObjects");

    when(ioService.readAllString(Paths.convert(sourcePath))).thenReturn("test source");

    DataObject dataObject = new DataObjectImpl("test",
                                               "TestSource");
    dataObject.addAnnotation(new AnnotationImpl(DriverUtils.buildAnnotationDefinition(PlanningSolution.class)));
    GenerationResult generationResult = new GenerationResult();
    generationResult.setDataObject(dataObject);
    when(dataModelerService.loadDataObject(any(),
                                           anyString(),
                                           any())).thenReturn(generationResult);

    Package _package = mock(Package.class);
    when(_package.getPackageMainResourcesPath()).thenReturn(PathFactory.newPath("dataObjects",
                                                                                "file:///dataObjects"));
    when(kieProjectService.resolvePackage(sourcePath)).thenReturn(_package);

    when(ioService.exists(any())).thenReturn(true);

    renameHelper.postProcess(sourcePath,
                             destinationPath);

    verify(ioService,
           times(1)).move(any(org.uberfire.java.nio.file.Path.class),
                          any(org.uberfire.java.nio.file.Path.class));
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:33,代码来源:PlanningSolutionRenameHelperTest.java

示例14: extractScoreTypeFqn

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
@Test
public void extractScoreTypeFqn() {
    DataObject dataObject = new DataObjectImpl("test",
                                               "Test");
    dataObject.addAnnotation(new AnnotationImpl(DriverUtils.buildAnnotationDefinition(PlanningSolution.class)));
    dataObject.addProperty("score",
                           HardSoftScore.class.getName());

    String result = scoreHolderUtils.extractScoreTypeFqn(dataObject);

    assertEquals(HardSoftScore.class.getName(),
                 result);
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:14,代码来源:ScoreHolderUtilsTest.java

示例15: checkDataObjectIsAPlanningSolution

import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
@Test
public void checkDataObjectIsAPlanningSolution() {
    DataObject dataObject = new DataObjectImpl("test",
                                               "Test");
    dataObject.addAnnotation(new AnnotationImpl(DriverUtils.buildAnnotationDefinition(PlanningSolution.class)));

    Collection<ValidationMessage> result = copyValidator.validate(mock(Path.class),
                                                                  dataObject);
    assertEquals(1,
                 result.size());

    ValidationMessage message = result.iterator().next();
    assertTrue(message instanceof PlanningSolutionToBeDuplicatedMessage);
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:15,代码来源:PlanningSolutionCopyValidatorTest.java


注:本文中的org.kie.workbench.common.services.datamodeller.core.DataObject.addAnnotation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。