1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.component.event

File ComponentDescriptorRemovedEventTest.java

 

Code metrics

0
8
4
2
74
38
4
0.5
2
2
1

Classes

Class Line # Actions
ComponentDescriptorRemovedEventTest 33 8 0% 4 2
0.833333383.3%
ComponentDescriptorRemovedEventTest.Dummy 38 0 - 0 0
-1.0 -
 

Contributing tests

This file is covered by 3 tests. .

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.component.event;
21   
22    import java.lang.reflect.Type;
23   
24    import org.junit.Assert;
25    import org.junit.Test;
26    import org.xwiki.observation.event.Event;
27   
28    /**
29    * Unit tests for {@link ComponentDescriptorRemovedEvent}.
30    *
31    * @version $Id: 767b7f4de6f1cc22d884653b6d8a6cd20220858c $
32    */
 
33    public class ComponentDescriptorRemovedEventTest
34    {
35    /**
36    * Used in tests below.
37    */
 
38    private static class Dummy
39    {
40    }
41   
 
42  1 toggle @Test
43    public void testMatchesAllComponentRoles()
44    {
45  1 ComponentDescriptorRemovedEvent event = new ComponentDescriptorRemovedEvent();
46    // Note: We use any class for the test but it's supposed to be a component role class.
47  1 Assert.assertTrue(event.matches(new ComponentDescriptorRemovedEvent((Type) Dummy.class, "rolehint")));
48    }
49   
 
50  1 toggle @Test
51    public void testMatchesWhenDifferentEvent()
52    {
53  1 ComponentDescriptorRemovedEvent event = new ComponentDescriptorRemovedEvent();
54  1 Assert.assertFalse(event.matches(new Event()
55    {
 
56  0 toggle @Override
57    public boolean matches(Object otherEvent)
58    {
59  0 return false;
60    }
61    }));
62    }
63   
 
64  1 toggle @Test
65    public void testMatchesWhenSpecificRoleSpecified()
66    {
67    // Note: We use any class for the test but it's supposed to be a component role class.
68  1 ComponentDescriptorRemovedEvent event = new ComponentDescriptorRemovedEvent((Type) Dummy.class);
69  1 Assert.assertTrue(event.matches(new ComponentDescriptorRemovedEvent((Type) Dummy.class, "rolehint")));
70    // Use a different class so that it doesn't match
71  1 Assert.assertFalse(event.matches(new ComponentDescriptorRemovedEvent((Type) ComponentDescriptorRemovedEvent.class,
72    "rolehint")));
73    }
74    }