SetDMNActiveModelCommand extends AbstractDMNModelCommand { @Override public DMNModel execute(Context context) { RegistryContext registryContext = (RegistryContext) context; DMNModel activeModel = getDMNModel(context);; registryContext.register(DMNModel.class, activeModel); return activeModel; } SetDMNActiveModelCommand(String namespace, String modelName);  SetDMNActiveModelCommand(String resourcePath); @Override DMNModel execute(Context context);  }
@Test public void execute() { String namespace = "http: String modelName = "typecheck in DT"; SetDMNActiveModelCommand setDMNActiveModelCommand = new SetDMNActiveModelCommand(namespace, modelName); assertThatThrownBy(() -> setDMNActiveModelCommand.execute(registryContext)) .isInstanceOf(IllegalStateException.class) .hasMessage("There is no DMNRuntime available"); registryContext.register(DMNRuntime.class, dmnRuntime); DMNModel dmnModel = setDMNActiveModelCommand.execute(registryContext); assertEquals(namespace, dmnModel.getNamespace()); assertEquals(modelName, dmnModel.getName()); }
@Test public void executeWithResource() { SetDMNActiveModelCommand setDMNActiveModelCommand = new SetDMNActiveModelCommand(resource.getSourcePath()); assertThatThrownBy(() -> setDMNActiveModelCommand.execute(registryContext)) .isInstanceOf(IllegalStateException.class) .hasMessage("There is no DMNRuntime available"); registryContext.register(DMNRuntime.class, dmnRuntime); DMNModel dmnModel = setDMNActiveModelCommand.execute(registryContext); assertEquals(resource.getSourcePath(), dmnModel.getResource().getSourcePath()); }