-
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathXmlRulesDefinitionTest.java
More file actions
88 lines (71 loc) · 4.26 KB
/
XmlRulesDefinitionTest.java
File metadata and controls
88 lines (71 loc) · 4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
* ecoCode Android plugin - Provides rules to reduce the environmental footprint of your Android applications
* Copyright © 2020 Green Code Initiative (contact@ecocode.io)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package io.ecocode.xml;
import org.junit.Test;
import org.sonar.api.server.rule.RulesDefinition;
import static org.assertj.core.api.Assertions.assertThat;
public class XmlRulesDefinitionTest {
@Test
public void test() {
XmlRulesDefinition rulesDefinition = new XmlRulesDefinition();
RulesDefinition.Context context = new RulesDefinition.Context();
rulesDefinition.define(context);
RulesDefinition.Repository repository = context.repository(Xml.REPOSITORY_KEY);
assertThat(repository.name()).isEqualTo(Xml.REPOSITORY_NAME);
assertThat(repository.language()).isEqualTo(Xml.KEY);
assertThat(repository.rules()).hasSize(XmlCheckList.getXmlChecks().size());
RulesDefinition.Rule serviceBootTimeXmlRule = repository.rule("EC540");
assertThat(serviceBootTimeXmlRule).isNotNull();
assertThat(serviceBootTimeXmlRule.name()).isEqualTo("Batch: Service Boot Time");
RulesDefinition.Rule keepScreenOnXmlRule = repository.rule("EC541");
assertThat(keepScreenOnXmlRule).isNotNull();
assertThat(keepScreenOnXmlRule.name()).isEqualTo("Idleness: Keep Screen On");
RulesDefinition.Rule keepCpuOnXmlRule = repository.rule("EC542");
assertThat(keepCpuOnXmlRule).isNotNull();
assertThat(keepCpuOnXmlRule.name()).isEqualTo("Idleness: Keep CPU On");
RulesDefinition.Rule compagnionInBackgroundXmlRule = repository.rule("EC543");
assertThat(compagnionInBackgroundXmlRule).isNotNull();
assertThat(compagnionInBackgroundXmlRule.name()).isEqualTo("Power: Compagnion In Background");
RulesDefinition.Rule ignoreBatteryOptimizationsXmlRule = repository.rule("EC544");
assertThat(ignoreBatteryOptimizationsXmlRule).isNotNull();
assertThat(ignoreBatteryOptimizationsXmlRule.name()).isEqualTo("Power: Ignore Battery Optimizations");
RulesDefinition.Rule chargeAwarenessXmlRule = repository.rule("EC545");
assertThat(chargeAwarenessXmlRule).isNotNull();
assertThat(chargeAwarenessXmlRule.name()).isEqualTo("Power: Charge Awareness");
RulesDefinition.Rule saveModeAwarenessXml = repository.rule("EC546");
assertThat(saveModeAwarenessXml).isNotNull();
assertThat(saveModeAwarenessXml.name()).isEqualTo("Power: Save Mode Awareness");
RulesDefinition.Rule darkUIBrightColorsXmlRule = repository.rule("EC547");
assertThat(darkUIBrightColorsXmlRule).isNotNull();
assertThat(darkUIBrightColorsXmlRule.name()).isEqualTo("Sobriety: Dark UI (Bright Colors)");
RulesDefinition.Rule darkUIThemeXmlRule = repository.rule("EC548");
assertThat(darkUIThemeXmlRule).isNotNull();
assertThat(darkUIThemeXmlRule.name()).isEqualTo("Sobriety: Dark UI (Theme)");
RulesDefinition.Rule hardwareAccelerationXml = repository.rule("EC549");
assertThat(hardwareAccelerationXml).isNotNull();
assertThat(hardwareAccelerationXml.name()).isEqualTo("Sobriety: Hardware acceleration");
RulesDefinition.Rule extraneousAnimationXmlRule = repository.rule("EC550");
assertThat(extraneousAnimationXmlRule).isNotNull();
assertThat(extraneousAnimationXmlRule.name()).isEqualTo("Power: Extraneous Animation");
for (RulesDefinition.Rule rule : repository.rules()) {
for (RulesDefinition.Param param : rule.params()) {
assertThat(param.description()).as("description for " + param.key()).isNotEmpty();
}
}
}
}