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

File DefaultEntityResourceActionListerTest.java

 

Code metrics

0
6
2
1
70
37
2
0.33
3
2
1

Classes

Class Line # Actions
DefaultEntityResourceActionListerTest 44 6 0% 2 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.resource.internal.entity;
21   
22    import javax.inject.Provider;
23   
24    import org.junit.Before;
25    import org.junit.Rule;
26    import org.junit.Test;
27    import org.xwiki.component.manager.ComponentManager;
28    import org.xwiki.component.util.DefaultParameterizedType;
29    import org.xwiki.environment.Environment;
30    import org.xwiki.resource.ResourceReferenceHandler;
31    import org.xwiki.resource.entity.EntityResourceAction;
32    import org.xwiki.test.mockito.MockitoComponentMockingRule;
33   
34    import static org.junit.Assert.assertThat;
35    import static org.hamcrest.CoreMatchers.hasItems;
36    import static org.mockito.Mockito.*;
37   
38    /**
39    * Unit tests for {@link DefaultEntityResourceActionLister}.
40    *
41    * @version $Id: c39e3a5d499e0f15a4b50d5f164b856a62ad218c $
42    * @since 7.2M1
43    */
 
44    public class DefaultEntityResourceActionListerTest
45    {
46    @Rule
47    public MockitoComponentMockingRule<DefaultEntityResourceActionLister> mocker =
48    new MockitoComponentMockingRule<>(DefaultEntityResourceActionLister.class);
49   
 
50  1 toggle @Before
51    public void configure() throws Exception
52    {
53  1 Provider<ComponentManager> componentManagerProvider = this.mocker.registerMockComponent(
54    new DefaultParameterizedType(null, Provider.class, ComponentManager.class), "context");
55  1 when(componentManagerProvider.get()).thenReturn(this.mocker);
56    }
57   
 
58  1 toggle @Test
59    public void listActions() throws Exception
60    {
61  1 Environment environment = this.mocker.getInstance(Environment.class);
62  1 when(environment.getResourceAsStream("/WEB-INF/struts-config.xml")).thenReturn(
63    getClass().getClassLoader().getResourceAsStream("WEB-INF/struts-config.xml"));
64   
65  1 this.mocker.registerMockComponent(new DefaultParameterizedType(null, ResourceReferenceHandler.class,
66    EntityResourceAction.class), "testaction");
67   
68  1 assertThat(this.mocker.getComponentUnderTest().listActions(), hasItems("view", "edit", "get", "testaction"));
69    }
70    }