1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.model.internal.reference

File DefaultEntityReferenceValueProviderTest.java

 

Code metrics

0
16
3
1
74
43
3
0.19
5.33
3
1

Classes

Class Line # Actions
DefaultEntityReferenceValueProviderTest 38 16 0% 3 0
1.0100%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.model.internal.reference;
21   
22    import org.jmock.Expectations;
23    import org.jmock.Mockery;
24    import org.junit.Assert;
25    import org.junit.Before;
26    import org.junit.Test;
27    import org.xwiki.component.util.ReflectionUtils;
28    import org.xwiki.model.EntityType;
29    import org.xwiki.model.ModelConfiguration;
30    import org.xwiki.model.reference.EntityReferenceValueProvider;
31   
32    /**
33    * Unit tests for the deprecated {@link org.xwiki.model.internal.reference.DefaultEntityReferenceValueProvider}.
34    *
35    * @version $Id: 19a13d3c9ee2917a5f519a346c395de5b8ccb0da $
36    * @since 2.3M1
37    */
 
38    public class DefaultEntityReferenceValueProviderTest
39    {
40    private Mockery mockery = new Mockery();
41   
42    private EntityReferenceValueProvider provider;
43   
 
44  1 toggle @Before
45    public void setUp()
46    {
47  1 this.provider = new DefaultEntityReferenceValueProvider();
48  1 final ModelConfiguration mockConfiguration = this.mockery.mock(ModelConfiguration.class);
49  1 ReflectionUtils.setFieldValue(this.provider, "configuration", mockConfiguration);
50   
51  1 this.mockery.checking(new Expectations()
52    {
 
53  1 toggle {
54  1 allowing(mockConfiguration).getDefaultReferenceValue(EntityType.SPACE);
55  1 will(returnValue("defspace"));
56  1 allowing(mockConfiguration).getDefaultReferenceValue(EntityType.WIKI);
57  1 will(returnValue("defwiki"));
58  1 allowing(mockConfiguration).getDefaultReferenceValue(EntityType.DOCUMENT);
59  1 will(returnValue("defpage"));
60  1 allowing(mockConfiguration).getDefaultReferenceValue(EntityType.ATTACHMENT);
61  1 will(returnValue("deffilename"));
62    }
63    });
64    }
65   
 
66  1 toggle @Test
67    public void testGetDefaultValue()
68    {
69  1 Assert.assertEquals("defpage", this.provider.getDefaultValue(EntityType.DOCUMENT));
70  1 Assert.assertEquals("defspace", this.provider.getDefaultValue(EntityType.SPACE));
71  1 Assert.assertEquals("deffilename", this.provider.getDefaultValue(EntityType.ATTACHMENT));
72  1 Assert.assertEquals("defwiki", this.provider.getDefaultValue(EntityType.WIKI));
73    }
74    }