PlannerDataObjectEditor extends ObjectEditor implements PlannerDataObjectEditorView.Presenter { void updatePlanningScoreProperty(final String newPlanningSolutionScoreType) { if (getDataObject() != null) { removePlanningScoreProperty(); addPlanningScoreProperty(newPlanningSolutionScoreType); } } @Inject  PlannerDataObjectEditor(PlannerDataObjectEditorView view,
                                   DomainHandlerRegistry handlerRegistry,
                                   Event<DataModelerEvent> dataModelerEvent,
                                   DataModelCommandBuilder commandBuilder,
                                   TranslationService translationService,
                                   Caller<ComparatorDefinitionService> comparatorDefinitionService,
                                   Caller<AssetsUsageService> assetsUsageServiceCaller); @Override Widget asWidget(); @Override String getName(); @Override String getDomainName(); @Override void clear(); @Override void objectPropertyPathChanged(List<ObjectPropertyPath> objectPropertyPaths,
                                          boolean itemsRemoved); @Override void removeComparatorDefinition(DataObject dataObject,
                                           boolean resetPlanningEntityAnnotation); @Override void onNotInPlanningChange(); @Override void onPlanningEntityChange(); @Override void onPlanningSolutionChange(); @Override void onPlanningSolutionScoreTypeChange(); @Override void onPlanningSolutionBendableScoreHardLevelsSizeChange(); @Override void onPlanningSolutionBendableScoreSoftLevelsSizeChange();  }
@Test public void updatePlanningScoreProperty() { PlannerDataObjectEditor objectEditor = createObjectEditor(); AnnotationDefinition planningScoreAnnotationDefinition = mock(AnnotationDefinition.class); when(planningScoreAnnotationDefinition.getClassName()).thenReturn(PlannerDomainAnnotations.PLANNING_SCORE_ANNOTATION); context.getAnnotationDefinitions().put(PlannerDomainAnnotations.PLANNING_SCORE_ANNOTATION, planningScoreAnnotationDefinition); context.getAnnotationDefinitions().put(PlannerDomainAnnotations.JAXB_XML_JAVA_TYPE_ADAPTER_ANNOTATION, mock(AnnotationDefinition.class)); context.getAnnotationDefinitions().put(Generated.class.getName(), mock(AnnotationDefinition.class)); objectEditor.onContextChange(context); DataObject dataObject = context.getDataObject(); Mockito.reset(view); objectEditor.updatePlanningScoreProperty(HardSoftScore.class.getName()); ObjectProperty scoreObjectProperty = dataObject.getProperty("score"); assertNotNull(scoreObjectProperty); assertEquals(HardSoftScore.class.getName(), scoreObjectProperty.getClassName()); Mockito.reset(view); when(view.getPlanningSolutionScoreType()).thenReturn(HardSoftScore.class.getName()); objectEditor.onPlanningSolutionScoreTypeChange(); scoreObjectProperty = dataObject.getProperty("score"); assertNotNull(scoreObjectProperty); assertEquals(HardSoftScore.class.getName(), scoreObjectProperty.getClassName()); Mockito.reset(view); when(view.getPlanningSolutionScoreType()).thenReturn(BendableScore.class.getName()); objectEditor.onPlanningSolutionScoreTypeChange(); scoreObjectProperty = dataObject.getProperty("score"); assertNotNull(scoreObjectProperty); assertNotNull(scoreObjectProperty.getAnnotation(PlannerDomainAnnotations.PLANNING_SCORE_ANNOTATION)); assertEquals(BendableScore.class.getName(), scoreObjectProperty.getClassName()); verify(view, times(1)).showPlanningSolutionBendableScoreInput(true); Mockito.reset(view); when(view.getPlanningSolutionScoreType()).thenReturn(BendableLongScore.class.getName()); objectEditor.onPlanningSolutionScoreTypeChange(); scoreObjectProperty = dataObject.getProperty("score"); assertNotNull(scoreObjectProperty); assertNotNull(scoreObjectProperty.getAnnotation(PlannerDomainAnnotations.PLANNING_SCORE_ANNOTATION)); assertEquals(BendableLongScore.class.getName(), scoreObjectProperty.getClassName()); verify(view, times(1)).showPlanningSolutionBendableScoreInput(true); Mockito.reset(view); when(view.getPlanningSolutionScoreType()).thenReturn(SimpleScore.class.getName()); objectEditor.onPlanningSolutionScoreTypeChange(); scoreObjectProperty = dataObject.getProperty("score"); assertNotNull(scoreObjectProperty); assertNotNull(scoreObjectProperty.getAnnotation(PlannerDomainAnnotations.PLANNING_SCORE_ANNOTATION)); assertEquals(SimpleScore.class.getName(), scoreObjectProperty.getClassName()); verify(view, times(1)).showPlanningSolutionBendableScoreInput(false); Mockito.reset(view); when(view.getPlanningSolutionScoreType()).thenReturn(""); objectEditor.onPlanningSolutionScoreTypeChange(); assertNull(dataObject.getProperty("score")); when(view.getNotInPlanningValue()).thenReturn(true); objectEditor.onNotInPlanningChange(); scoreObjectProperty = dataObject.getProperty("score"); assertNull(scoreObjectProperty); verify(view, times(1)).showPlanningSolutionScoreType(false); }