Skip to content

Package: EMFFormsLabelProviderDefaultImpl_Test

EMFFormsLabelProviderDefaultImpl_Test

nameinstructionbranchcomplexitylinemethod
EMFFormsLabelProviderDefaultImpl_Test()
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%
setUp()
M: 0 C: 60
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 12
100%
M: 0 C: 1
100%
tearDown()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
testGetDescriptionEClass()
M: 0 C: 74
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 13
100%
M: 0 C: 1
100%
testGetDescriptionEClassBothNull()
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
testGetDescriptionEClassDMRNull()
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
testGetDescriptionEClassEClassNull()
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
testGetDescriptionOneParam()
M: 0 C: 77
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 13
100%
M: 0 C: 1
100%
testGetDescriptionOneParamDynamicEMF()
M: 0 C: 69
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 13
100%
M: 0 C: 1
100%
testGetDescriptionOneParamNull()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
testGetDescriptionTwoParams()
M: 0 C: 76
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 14
100%
M: 0 C: 1
100%
testGetDescriptionTwoParamsBothNull()
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
testGetDescriptionTwoParamsObjectNull()
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
testGetDescriptionTwoParamsReferenceNull()
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
testGetDisplayNameEClass()
M: 0 C: 74
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 13
100%
M: 0 C: 1
100%
testGetDisplayNameEClassBothNull()
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
testGetDisplayNameEClassDMRNull()
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
testGetDisplayNameEClassEClassNull()
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
testGetDisplayNameOneParam()
M: 0 C: 77
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 13
100%
M: 0 C: 1
100%
testGetDisplayNameOneParamDynamicEMF()
M: 0 C: 33
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
testGetDisplayNameOneParamFeature()
M: 0 C: 48
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 9
100%
M: 0 C: 1
100%
testGetDisplayNameOneParamNull()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
testGetDisplayNameTwoParams()
M: 0 C: 76
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 14
100%
M: 0 C: 1
100%
testGetDisplayNameTwoParamsBothNull()
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
testGetDisplayNameTwoParamsObjectNull()
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
testGetDisplayNameTwoParamsReferenceNull()
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2018 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: * Lucas Koehler - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.internal.core.services.label;
15:
16: import static org.junit.Assert.assertEquals;
17: import static org.mockito.Matchers.any;
18: import static org.mockito.Matchers.isNull;
19: import static org.mockito.Matchers.same;
20: import static org.mockito.Mockito.mock;
21: import static org.mockito.Mockito.verify;
22: import static org.mockito.Mockito.when;
23:
24: import org.eclipse.core.databinding.observable.value.IObservableValue;
25: import org.eclipse.emf.databinding.EObjectObservableValue;
26: import org.eclipse.emf.databinding.IEMFValueProperty;
27: import org.eclipse.emf.ecore.EClass;
28: import org.eclipse.emf.ecore.EObject;
29: import org.eclipse.emf.ecore.EStructuralFeature;
30: import org.eclipse.emf.ecore.EcoreFactory;
31: import org.eclipse.emf.ecp.test.common.DefaultRealm;
32: import org.eclipse.emf.ecp.view.spi.model.VDomainModelReference;
33: import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
34: import org.eclipse.emfforms.core.services.databinding.testmodel.test.model.D;
35: import org.eclipse.emfforms.core.services.databinding.testmodel.test.model.TestPackage;
36: import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedException;
37: import org.eclipse.emfforms.spi.core.services.databinding.emf.EMFFormsDatabindingEMF;
38: import org.eclipse.emfforms.spi.core.services.emfspecificservice.EMFSpecificService;
39: import org.junit.After;
40: import org.junit.Before;
41: import org.junit.Test;
42:
43: /**
44: * JUnit tests for {@link EMFFormsLabelProviderImpl}.
45: *
46: * @author Lucas Koehler
47: *
48: */
49: @SuppressWarnings("deprecation")
50: public class EMFFormsLabelProviderDefaultImpl_Test {
51:
52:         private EMFFormsLabelProviderDefaultImpl labelProvider;
53:         private EMFSpecificService emfSpecificService;
54:         private IItemPropertyDescriptor itemPropertyDescriptor;
55:         private IEMFValueProperty valueProperty;
56:         private EObjectObservableValue observableValue;
57:         private EMFFormsDatabindingEMF databindingService;
58:         private DefaultRealm defaultRealm;
59:
60:         /**
61:          * Set up that is executed before every test case.
62:          * Registers a databinding and an emf specific service.
63:          * Mocks various objects for the tests.
64:          */
65:         @Before
66:         public void setUp() {
67:                 defaultRealm = new DefaultRealm();
68:                 labelProvider = new EMFFormsLabelProviderDefaultImpl();
69:
70:                 databindingService = mock(EMFFormsDatabindingEMF.class);
71:                 labelProvider.setEMFFormsDatabinding(databindingService);
72:
73:                 valueProperty = mock(IEMFValueProperty.class);
74:                 observableValue = mock(EObjectObservableValue.class);
75:                 // when(observableValue.getRealm()).thenReturn(Realm.getDefault());
76:
77:                 emfSpecificService = mock(EMFSpecificService.class);
78:                 labelProvider.setEMFSpecificService(emfSpecificService);
79:
80:                 itemPropertyDescriptor = mock(IItemPropertyDescriptor.class);
81:                 when(emfSpecificService.getIItemPropertyDescriptor(any(EObject.class), any(EStructuralFeature.class)))
82:                         .thenReturn(itemPropertyDescriptor);
83:         }
84:
85:         /**
86:          * Clean up the realm.
87:          */
88:         @After
89:         public void tearDown() {
90:                 defaultRealm.dispose();
91:         }
92:
93:         /**
94:          * Test method for
95:          * {@link EMFFormsLabelProviderDefaultImpl#getDisplayName(EStructuralFeature)}
96:          * .
97:          *
98:          * @throws DatabindingFailedException should not happen, just needs to be thrown because the databinding service
99:          * defines the throw in its interface.
100:          */
101:         @Test
102:         public void testGetDisplayNameOneParamDynamicEMF() throws DatabindingFailedException {
103:                 final String expectedResult = "Expected"; //$NON-NLS-1$
104:                 final EStructuralFeature structuralFeature = mock(EStructuralFeature.class);
105:                 final EClass eClass = EcoreFactory.eINSTANCE.createEClass();
106:                 when(structuralFeature.getEContainingClass()).thenReturn(eClass);
107:                 when(structuralFeature.getName()).thenReturn(expectedResult.toLowerCase());
108:                 final String result = (String) labelProvider.getDisplayName(structuralFeature).getValue();
109:
110:                 assertEquals(expectedResult, result);
111:         }
112:
113:         /**
114:          * Test method for
115:          * {@link EMFFormsLabelProviderDefaultImpl#getDisplayName(EStructuralFeature)}
116:          * .
117:          *
118:          * @throws DatabindingFailedException should not happen, just needs to be thrown because the databinding service
119:          * defines the throw in its interface.
120:          */
121:         @Test
122:         public void testGetDisplayNameOneParamFeature() throws DatabindingFailedException {
123:                 final String expectedResult = "expected"; //$NON-NLS-1$
124:                 final EStructuralFeature structuralFeature = mock(EStructuralFeature.class);
125:
126:                 when(structuralFeature.getEContainingClass()).thenReturn(TestPackage.eINSTANCE.getD());
127:                 when(itemPropertyDescriptor.getDisplayName(any(Object.class))).thenReturn(expectedResult);
128:                 when(valueProperty.getValueType()).thenReturn(structuralFeature);
129:
130:                 final String result = (String) labelProvider.getDisplayName(structuralFeature).getValue();
131:
132:                 verify(itemPropertyDescriptor).getDisplayName(any(D.class));
133:                 assertEquals(expectedResult, result);
134:         }
135:
136:         /**
137:          * Test method for
138:          * {@link EMFFormsLabelProviderDefaultImpl#getDisplayName(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference)}
139:          * .
140:          *
141:          * @throws DatabindingFailedException should not happen, just needs to be thrown because the databinding service
142:          * defines the throw in its interface.
143:          */
144:         @Test
145:         public void testGetDisplayNameOneParam() throws DatabindingFailedException {
146:                 final String expectedResult = "expected"; //$NON-NLS-1$
147:                 final EStructuralFeature structuralFeature = mock(EStructuralFeature.class);
148:                 final VDomainModelReference domainModelReference = mock(VDomainModelReference.class);
149:
150:                 when(structuralFeature.getEContainingClass()).thenReturn(TestPackage.eINSTANCE.getD());
151:                 when(itemPropertyDescriptor.getDisplayName(any(Object.class))).thenReturn(expectedResult);
152:                 when(valueProperty.getValueType()).thenReturn(structuralFeature);
153:                 when(databindingService.getValueProperty(same(domainModelReference), isNull(EObject.class)))
154:                         .thenReturn(valueProperty);
155:
156:                 final IObservableValue result = labelProvider.getDisplayName(domainModelReference);
157:
158:                 verify(databindingService).getValueProperty(same(domainModelReference), isNull(EObject.class));
159:                 verify(itemPropertyDescriptor).getDisplayName(any(D.class));
160:                 assertEquals(expectedResult, result.getValue());
161:         }
162:
163:         /**
164:          * Test method for
165:          * {@link EMFFormsLabelProviderDefaultImpl#getDisplayName(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference)}
166:          * .
167:          */
168:         @Test(expected = IllegalArgumentException.class)
169:         public void testGetDisplayNameOneParamNull() {
170:                 labelProvider.getDisplayName((VDomainModelReference) null);
171:         }
172:
173:         /**
174:          * Test method for
175:          * {@link EMFFormsLabelProviderDefaultImpl#getDisplayName(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference, org.eclipse.emf.ecore.EClass)}
176:          * .
177:          *
178:          * @throws DatabindingFailedException should not happen, just needs to be thrown because the databinding service
179:          * defines the throw in its interface.
180:          */
181:         @Test
182:         public void testGetDisplayNameEClass() throws DatabindingFailedException {
183:                 final String expectedResult = "expected"; //$NON-NLS-1$
184:                 final EStructuralFeature structuralFeature = mock(EStructuralFeature.class);
185:                 final VDomainModelReference domainModelReference = mock(VDomainModelReference.class);
186:                 final EClass eClass = mock(EClass.class);
187:
188:                 when(structuralFeature.getEContainingClass()).thenReturn(TestPackage.eINSTANCE.getD());
189:                 when(itemPropertyDescriptor.getDisplayName(any(Object.class))).thenReturn(expectedResult);
190:                 when(valueProperty.getValueType()).thenReturn(structuralFeature);
191:                 when(databindingService.getValueProperty(domainModelReference, eClass)).thenReturn(valueProperty);
192:
193:                 final IObservableValue result = labelProvider.getDisplayName(domainModelReference, eClass);
194:
195:                 verify(databindingService).getValueProperty(domainModelReference, eClass);
196:                 verify(itemPropertyDescriptor).getDisplayName(any(D.class));
197:                 assertEquals(expectedResult, result.getValue());
198:         }
199:
200:         /**
201:          * Test method for
202:          * {@link EMFFormsLabelProviderDefaultImpl#getDisplayName(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference, org.eclipse.emf.ecore.EClass)}
203:          * .
204:          */
205:         @Test(expected = IllegalArgumentException.class)
206:         public void testGetDisplayNameEClassDMRNull() {
207:                 labelProvider.getDisplayName((VDomainModelReference) null, mock(EClass.class));
208:         }
209:
210:         /**
211:          * Test method for
212:          * {@link EMFFormsLabelProviderDefaultImpl#getDisplayName(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference, org.eclipse.emf.ecore.EClass)}
213:          * .
214:          */
215:         @Test(expected = IllegalArgumentException.class)
216:         public void testGetDisplayNameEClassEClassNull() {
217:                 labelProvider.getDisplayName(mock(VDomainModelReference.class), null);
218:         }
219:
220:         /**
221:          * Test method for
222:          * {@link EMFFormsLabelProviderDefaultImpl#getDisplayName(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference)}
223:          * .
224:          */
225:         @Test(expected = IllegalArgumentException.class)
226:         public void testGetDisplayNameEClassBothNull() {
227:                 labelProvider.getDisplayName(null, null);
228:         }
229:
230:         /**
231:          * Test method for
232:          * {@link EMFFormsLabelProviderDefaultImpl#getDisplayName(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference, org.eclipse.emf.ecore.EObject)}
233:          * .
234:          *
235:          * @throws DatabindingFailedException should not happen, just needs to be thrown because the databinding service
236:          * defines the throw in its interface.
237:          */
238:         @Test
239:         public void testGetDisplayNameTwoParams() throws DatabindingFailedException {
240:                 final String expectedResult = "expected"; //$NON-NLS-1$
241:                 final EObject eObject = mock(EObject.class);
242:                 final EObject value = mock(EObject.class);
243:                 final EStructuralFeature structuralFeature = mock(EStructuralFeature.class);
244:                 final VDomainModelReference domainModelReference = mock(VDomainModelReference.class);
245:
246:                 when(itemPropertyDescriptor.getDisplayName(value)).thenReturn(expectedResult);
247:                 when(observableValue.getValueType()).thenReturn(structuralFeature);
248:                 when(observableValue.getObserved()).thenReturn(value);
249:                 when(databindingService.getObservableValue(domainModelReference, eObject)).thenReturn(observableValue);
250:                 final IObservableValue result = labelProvider.getDisplayName(domainModelReference, eObject);
251:
252:                 verify(databindingService).getObservableValue(domainModelReference, eObject);
253:                 verify(itemPropertyDescriptor).getDisplayName(value);
254:                 assertEquals(expectedResult, result.getValue());
255:         }
256:
257:         /**
258:          * Test method for
259:          * {@link EMFFormsLabelProviderDefaultImpl#getDisplayName(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference, org.eclipse.emf.ecore.EObject)}
260:          * .
261:          */
262:         @Test(expected = IllegalArgumentException.class)
263:         public void testGetDisplayNameTwoParamsReferenceNull() {
264:                 labelProvider.getDisplayName(null, mock(EObject.class));
265:         }
266:
267:         /**
268:          * Test method for
269:          * {@link EMFFormsLabelProviderDefaultImpl#getDisplayName(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference, org.eclipse.emf.ecore.EObject)}
270:          * .
271:          */
272:         @Test(expected = IllegalArgumentException.class)
273:         public void testGetDisplayNameTwoParamsObjectNull() {
274:                 labelProvider.getDisplayName(mock(VDomainModelReference.class), null);
275:         }
276:
277:         /**
278:          * Test method for
279:          * {@link EMFFormsLabelProviderDefaultImpl#getDisplayName(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference, org.eclipse.emf.ecore.EObject)}
280:          * .
281:          */
282:         @Test(expected = IllegalArgumentException.class)
283:         public void testGetDisplayNameTwoParamsBothNull() {
284:                 labelProvider.getDisplayName(null, null);
285:         }
286:
287:         /**
288:          * Test method for
289:          * {@link EMFFormsLabelProviderDefaultImpl#getDisplayName(EStructuralFeature)}
290:          * .
291:          *
292:          * @throws DatabindingFailedException should not happen, just needs to be thrown because the databinding service
293:          * defines the throw in its interface.
294:          */
295:         @Test
296:         public void testGetDescriptionOneParamDynamicEMF() throws DatabindingFailedException {
297:                 final String expectedResult = "Expected"; //$NON-NLS-1$
298:                 final EStructuralFeature structuralFeature = mock(EStructuralFeature.class);
299:                 final EClass eClass = EcoreFactory.eINSTANCE.createEClass();
300:                 final VDomainModelReference domainModelReference = mock(VDomainModelReference.class);
301:
302:                 when(structuralFeature.getEContainingClass()).thenReturn(eClass);
303:                 when(structuralFeature.getName()).thenReturn(expectedResult.toLowerCase());
304:                 when(valueProperty.getValueType()).thenReturn(structuralFeature);
305:                 when(databindingService.getValueProperty(same(domainModelReference), isNull(EObject.class)))
306:                         .thenReturn(valueProperty);
307:
308:                 final IObservableValue result = labelProvider.getDescription(domainModelReference);
309:
310:                 verify(databindingService).getValueProperty(same(domainModelReference), isNull(EObject.class));
311:                 assertEquals(expectedResult, result.getValue());
312:         }
313:
314:         /**
315:          * Test method for
316:          * {@link EMFFormsLabelProviderDefaultImpl#getDescription(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference)}
317:          * .
318:          *
319:          * @throws DatabindingFailedException should not happen, just needs to be thrown because the databinding service
320:          * defines the throw in its interface.
321:          */
322:         @Test
323:         public void testGetDescriptionOneParam() throws DatabindingFailedException {
324:                 final String expectedResult = "expected"; //$NON-NLS-1$
325:                 final EStructuralFeature structuralFeature = mock(EStructuralFeature.class);
326:                 final VDomainModelReference domainModelReference = mock(VDomainModelReference.class);
327:
328:                 when(structuralFeature.getEContainingClass()).thenReturn(TestPackage.eINSTANCE.getD());
329:                 when(itemPropertyDescriptor.getDescription(any(Object.class))).thenReturn(expectedResult);
330:                 when(valueProperty.getValueType()).thenReturn(structuralFeature);
331:                 when(databindingService.getValueProperty(same(domainModelReference), isNull(EObject.class)))
332:                         .thenReturn(valueProperty);
333:
334:                 final IObservableValue result = labelProvider.getDescription(domainModelReference);
335:
336:                 verify(databindingService).getValueProperty(same(domainModelReference), isNull(EObject.class));
337:                 verify(itemPropertyDescriptor).getDescription(any(D.class));
338:                 assertEquals(expectedResult, result.getValue());
339:         }
340:
341:         /**
342:          * Test method for
343:          * {@link EMFFormsLabelProviderDefaultImpl#getDescription(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference)}
344:          * .
345:          */
346:         @Test(expected = IllegalArgumentException.class)
347:         public void testGetDescriptionOneParamNull() {
348:                 labelProvider.getDescription(null);
349:         }
350:
351:         /**
352:          * Test method for
353:          * {@link EMFFormsLabelProviderDefaultImpl#getDescription(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference, org.eclipse.emf.ecore.EClass)}
354:          * .
355:          *
356:          * @throws DatabindingFailedException should not happen, just needs to be thrown because the databinding service
357:          * defines the throw in its interface.
358:          */
359:         @Test
360:         public void testGetDescriptionEClass() throws DatabindingFailedException {
361:                 final String expectedResult = "expected"; //$NON-NLS-1$
362:                 final EStructuralFeature structuralFeature = mock(EStructuralFeature.class);
363:                 final VDomainModelReference domainModelReference = mock(VDomainModelReference.class);
364:                 final EClass eClass = mock(EClass.class);
365:
366:                 when(structuralFeature.getEContainingClass()).thenReturn(TestPackage.eINSTANCE.getD());
367:                 when(itemPropertyDescriptor.getDescription(any(Object.class))).thenReturn(expectedResult);
368:                 when(valueProperty.getValueType()).thenReturn(structuralFeature);
369:                 when(databindingService.getValueProperty(domainModelReference, eClass)).thenReturn(valueProperty);
370:
371:                 final IObservableValue result = labelProvider.getDescription(domainModelReference, eClass);
372:
373:                 verify(databindingService).getValueProperty(domainModelReference, eClass);
374:                 verify(itemPropertyDescriptor).getDescription(any(D.class));
375:                 assertEquals(expectedResult, result.getValue());
376:         }
377:
378:         /**
379:          * Test method for
380:          * {@link EMFFormsLabelProviderDefaultImpl#getDescription(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference, org.eclipse.emf.ecore.EClass)}
381:          * .
382:          */
383:         @Test(expected = IllegalArgumentException.class)
384:         public void testGetDescriptionEClassDMRNull() {
385:                 labelProvider.getDescription(null, mock(EClass.class));
386:         }
387:
388:         /**
389:          * Test method for
390:          * {@link EMFFormsLabelProviderDefaultImpl#getDescription(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference, org.eclipse.emf.ecore.EClass)}
391:          * .
392:          */
393:         @Test(expected = IllegalArgumentException.class)
394:         public void testGetDescriptionEClassEClassNull() {
395:                 labelProvider.getDescription(mock(VDomainModelReference.class), null);
396:         }
397:
398:         /**
399:          * Test method for
400:          * {@link EMFFormsLabelProviderDefaultImpl#getDescription(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference, org.eclipse.emf.ecore.EClass)}
401:          * .
402:          */
403:         @Test(expected = IllegalArgumentException.class)
404:         public void testGetDescriptionEClassBothNull() {
405:                 labelProvider.getDescription(null, null);
406:         }
407:
408:         /**
409:          * Test method for
410:          * {@link EMFFormsLabelProviderDefaultImpl#getDescription(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference, org.eclipse.emf.ecore.EObject)}
411:          * .
412:          *
413:          * @throws DatabindingFailedException should not happen, just needs to be thrown because the databinding service
414:          * defines the throw in its interface.
415:          */
416:         @Test
417:         public void testGetDescriptionTwoParams() throws DatabindingFailedException {
418:                 final String expectedResult = "expected"; //$NON-NLS-1$
419:                 final EObject eObject = mock(EObject.class);
420:                 final EObject value = mock(EObject.class);
421:                 final EStructuralFeature structuralFeature = mock(EStructuralFeature.class);
422:                 final VDomainModelReference domainModelReference = mock(VDomainModelReference.class);
423:
424:                 when(itemPropertyDescriptor.getDescription(value)).thenReturn(expectedResult);
425:                 when(observableValue.getValueType()).thenReturn(structuralFeature);
426:                 when(observableValue.getObserved()).thenReturn(value);
427:                 when(databindingService.getObservableValue(domainModelReference, eObject)).thenReturn(observableValue);
428:                 final IObservableValue result = labelProvider.getDescription(domainModelReference, eObject);
429:
430:                 verify(databindingService).getObservableValue(domainModelReference, eObject);
431:                 verify(itemPropertyDescriptor).getDescription(value);
432:                 assertEquals(expectedResult, result.getValue());
433:         }
434:
435:         /**
436:          * Test method for
437:          * {@link EMFFormsLabelProviderDefaultImpl#getDescription(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference, org.eclipse.emf.ecore.EObject)}
438:          * .
439:          */
440:         @Test(expected = IllegalArgumentException.class)
441:         public void testGetDescriptionTwoParamsReferenceNull() {
442:                 labelProvider.getDescription(null, mock(EObject.class));
443:         }
444:
445:         /**
446:          * Test method for
447:          * {@link EMFFormsLabelProviderDefaultImpl#getDescription(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference, org.eclipse.emf.ecore.EObject)}
448:          * .
449:          */
450:         @Test(expected = IllegalArgumentException.class)
451:         public void testGetDescriptionTwoParamsObjectNull() {
452:                 labelProvider.getDescription(mock(VDomainModelReference.class), null);
453:         }
454:
455:         /**
456:          * Test method for
457:          * {@link EMFFormsLabelProviderDefaultImpl#getDescription(org.eclipse.emf.ecp.view.spi.model.VDomainModelReference, org.eclipse.emf.ecore.EObject)}
458:          * .
459:          */
460:         @Test(expected = IllegalArgumentException.class)
461:         public void testGetDescriptionTwoParamsBothNull() {
462:                 labelProvider.getDescription(null, null);
463:         }
464: }