1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.extension.test

File ConfigurableDefaultCoreExtensionRepository.java

 

Coverage histogram

../../../../img/srcFileCovDistChart9.png
41% of files have more coverage

Code metrics

4
12
6
2
86
53
8
0.67
2
3
1.33

Classes

Class Line # Actions
ConfigurableDefaultCoreExtensionRepository 35 11 0% 7 2
0.990%
ConfigurableDefaultCoreExtensionRepository.ConfigurableEnvironmentExtension 37 1 0% 1 0
1.0100%
 

Contributing tests

This file is covered by 67 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.extension.test;
21   
22    import java.util.Arrays;
23   
24    import javax.inject.Singleton;
25   
26    import org.xwiki.component.annotation.Component;
27    import org.xwiki.extension.CoreExtension;
28    import org.xwiki.extension.ExtensionId;
29    import org.xwiki.extension.repository.internal.core.DefaultCoreExtension;
30    import org.xwiki.extension.repository.internal.core.DefaultCoreExtensionRepository;
31    import org.xwiki.extension.version.Version;
32   
33    @Component(staticRegistration = false)
34    @Singleton
 
35    public class ConfigurableDefaultCoreExtensionRepository extends DefaultCoreExtensionRepository
36    {
 
37    public class ConfigurableEnvironmentExtension extends DefaultCoreExtension
38    {
 
39  173 toggle public ConfigurableEnvironmentExtension(DefaultCoreExtensionRepository repository)
40    {
41  173 super(repository, null, new ExtensionId("environment", "version"), "type");
42    }
43    }
44   
45    private ConfigurableEnvironmentExtension configurableEnvironmentExtension;
46   
 
47  173 toggle public ConfigurableDefaultCoreExtensionRepository()
48    {
49  173 this.configurableEnvironmentExtension = new ConfigurableEnvironmentExtension(this);
50    }
51   
 
52  60 toggle @Override
53    public CoreExtension getEnvironmentExtension()
54    {
55  60 CoreExtension coreExtension = super.getEnvironmentExtension();
56   
57  60 return coreExtension != null ? coreExtension : getConfigurableEnvironmentExtension();
58    }
59   
 
60  62 toggle public ConfigurableEnvironmentExtension getConfigurableEnvironmentExtension()
61    {
62  62 return this.configurableEnvironmentExtension;
63    }
64   
 
65  0 toggle @Override
66    public void addExtension(DefaultCoreExtension extension)
67    {
68  0 super.addExtension(extension);
69    }
70   
 
71  178 toggle public void addExtensions(String id, Version version, ExtensionId... features)
72    {
73  178 DefaultCoreExtension coreExtension =
74    new DefaultCoreExtension(null, null, new ExtensionId(id, version), "unknown");
75   
76  178 if (features.length > 0) {
77  5 coreExtension.setExtensionFeatures(Arrays.asList(features));
78    }
79   
80  178 this.extensions.put(id, coreExtension);
81   
82  178 for (ExtensionId feature : coreExtension.getExtensionFeatures()) {
83  6 this.extensions.put(feature.getId(), coreExtension);
84    }
85    }
86    }