Skip to content

Package: CustomControlValidation_PTest

CustomControlValidation_PTest

nameinstructionbranchcomplexitylinemethod
CustomControlValidation_PTest()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
init()
M: 0 C: 37
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 13
100%
M: 0 C: 1
100%
testValidateChangeInvalidToValid()
M: 0 C: 23
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
testValidateChangeValidToInvalid()
M: 0 C: 26
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
testValidateOnInitInvalid()
M: 0 C: 18
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
testValidateOnInitValid()
M: 0 C: 23
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2013 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Eugen Neufeld - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.custom.ui.swt.test;
15:
16: import static org.junit.Assert.assertEquals;
17:
18: import org.eclipse.emf.common.util.Diagnostic;
19: import org.eclipse.emf.ecp.view.spi.context.ViewModelContextFactory;
20: import org.eclipse.emf.ecp.view.spi.custom.model.VCustomControl;
21: import org.eclipse.emf.ecp.view.spi.custom.model.VCustomDomainModelReference;
22: import org.eclipse.emf.ecp.view.spi.custom.model.VCustomFactory;
23: import org.eclipse.emf.ecp.view.spi.model.VView;
24: import org.eclipse.emf.ecp.view.spi.model.VViewFactory;
25: import org.eclipse.emf.ecp.view.test.common.swt.spi.DatabindingClassRunner;
26: import org.eclipse.emf.emfstore.bowling.BowlingFactory;
27: import org.eclipse.emf.emfstore.bowling.Player;
28: import org.junit.Before;
29: import org.junit.Test;
30: import org.junit.runner.RunWith;
31:
32: /**
33: * @author Eugen Neufeld
34: *
35: */
36: @RunWith(DatabindingClassRunner.class)
37: public class CustomControlValidation_PTest {
38:
39:         private VCustomControl modelControl;
40:         private VView view;
41:
42:         @Before
43:         public void init() {
44:                 view = VViewFactory.eINSTANCE.createView();
45:                 modelControl = VCustomFactory.eINSTANCE.createCustomControl();
46:                 final VCustomDomainModelReference domainModelReference = VCustomFactory.eINSTANCE
47:                         .createCustomDomainModelReference();
48:                 modelControl.setDomainModelReference(domainModelReference);
49:                 // domainModelReference.setControlId("org.eclipse.emf.ecp.view.custom.ui.swt.test.ValidatiuonCustomControl");
50:                 modelControl.setBundleName("org.eclipse.emf.ecp.view.custom.ui.swt.test");
51:                 modelControl
52:                         .setClassName("org.eclipse.emf.ecp.view.custom.ui.swt.test.ValidationCustomControl");
53:
54:                 domainModelReference.setBundleName("org.eclipse.emf.ecp.view.custom.ui.swt.test");
55:                 domainModelReference
56:                         .setClassName("org.eclipse.emf.ecp.view.custom.ui.swt.test.ValidationCustomControl");
57:
58:                 view.getChildren().add(modelControl);
59:         }
60:
61:         @Test
62:         public void testValidateOnInitValid() {
63:                 final Player player = BowlingFactory.eINSTANCE.createPlayer();
64:                 player.getEMails().add("bla");
65:
66:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, player);
67:
68:                 assertEquals("Severity must be ok", Diagnostic.OK, modelControl.getDiagnostic().getHighestSeverity());
69:         }
70:
71:         @Test
72:         public void testValidateOnInitInvalid() {
73:                 final Player player = BowlingFactory.eINSTANCE.createPlayer();
74:
75:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, player);
76:                 assertEquals("Severity must be error", Diagnostic.ERROR, modelControl.getDiagnostic().getHighestSeverity());
77:         }
78:
79:         @Test
80:         public void testValidateChangeValidToInvalid() {
81:                 final Player player = BowlingFactory.eINSTANCE.createPlayer();
82:                 player.getEMails().add("bla");
83:
84:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, player);
85:                 player.getEMails().clear();
86:                 assertEquals("Severity must be error", Diagnostic.ERROR, modelControl.getDiagnostic().getHighestSeverity());
87:         }
88:
89:         @Test
90:         public void testValidateChangeInvalidToValid() {
91:                 final Player player = BowlingFactory.eINSTANCE.createPlayer();
92:
93:                 ViewModelContextFactory.INSTANCE.createViewModelContext(view, player);
94:                 player.getEMails().add("bla");
95:                 assertEquals("Severity must be ok", Diagnostic.OK, modelControl.getDiagnostic().getHighestSeverity());
96:
97:         }
98:
99: }