| /** |
| * |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| * |
| */ |
| package org.eclipse.osbp.ecview.core.ui.common.tests.editparts.emf.validation; |
| |
| import org.junit.Assert; |
| import org.junit.Test; |
| import org.eclipse.osbp.ecview.core.common.context.ViewContext; |
| import org.eclipse.osbp.ecview.core.common.editpart.DelegatingEditPartManager; |
| import org.eclipse.osbp.ecview.core.common.editpart.validation.IValidatorEditpart; |
| import org.eclipse.osbp.ecview.core.common.model.validation.ValidationFactory; |
| import org.eclipse.osbp.ecview.core.common.model.validation.YValidator; |
| import org.eclipse.osbp.runtime.common.dispose.IDisposable; |
| |
| public class ValidationEditpartTest { |
| |
| private DelegatingEditPartManager editpartManager = DelegatingEditPartManager |
| .getInstance(); |
| |
| /** |
| * Tests the disposal. |
| */ |
| @Test |
| // BEGIN SUPRESS CATCH EXCEPTION |
| public void test_dispose() { |
| // END SUPRESS CATCH EXCEPTION |
| // ...> yLayout1 |
| // ......> yField1 |
| YValidator yValidator = ValidationFactory.eINSTANCE |
| .createYMaxLengthValidator(); |
| IValidatorEditpart validatorEditpart = editpartManager |
| .getEditpart(new ViewContext(), yValidator); |
| |
| Assert.assertFalse(validatorEditpart.isDisposed()); |
| validatorEditpart.dispose(); |
| Assert.assertTrue(validatorEditpart.isDisposed()); |
| |
| validatorEditpart.isDisposed(); |
| validatorEditpart.dispose(); |
| |
| try { |
| validatorEditpart.addDisposeListener(new IDisposable.Listener() { |
| @Override |
| public void notifyDisposed(IDisposable notifier) { |
| } |
| }); |
| Assert.fail(); |
| // BEGIN SUPRESS CATCH EXCEPTION |
| } catch (Exception e) { |
| // END SUPRESS CATCH EXCEPTION |
| // expected |
| } |
| |
| try { |
| validatorEditpart.getId(); |
| Assert.fail(); |
| // BEGIN SUPRESS CATCH EXCEPTION |
| } catch (Exception e) { |
| // END SUPRESS CATCH EXCEPTION |
| // expected |
| } |
| |
| try { |
| validatorEditpart.getModel(); |
| Assert.fail(); |
| // BEGIN SUPRESS CATCH EXCEPTION |
| } catch (Exception e) { |
| // END SUPRESS CATCH EXCEPTION |
| // expected |
| } |
| |
| try { |
| validatorEditpart.getValidator(); |
| Assert.fail(); |
| // BEGIN SUPRESS CATCH EXCEPTION |
| } catch (Exception e) { |
| // END SUPRESS CATCH EXCEPTION |
| // expected |
| } |
| |
| try { |
| validatorEditpart.removeDisposeListener(new IDisposable.Listener() { |
| @Override |
| public void notifyDisposed(IDisposable notifier) { |
| } |
| }); |
| Assert.fail(); |
| // BEGIN SUPRESS CATCH EXCEPTION |
| } catch (Exception e) { |
| // END SUPRESS CATCH EXCEPTION |
| // expected |
| } |
| |
| } |
| |
| } |