Skip to content
This repository was archived by the owner on Mar 11, 2019. It is now read-only.

Commit dad1b53

Browse files
author
Unknown
committed
Addition of unit tests
none.
1 parent 0fa190f commit dad1b53

File tree

10 files changed

+585
-258
lines changed

10 files changed

+585
-258
lines changed

.idea/workspace.xml

Lines changed: 384 additions & 247 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

main.nzprofile.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"color_settings":{"color_4":{"color_G":12,"color_R":13,"color_B":14},"color_5":{"color_G":15,"color_R":16,"color_B":17},"color_6":{"color_G":18,"color_R":19,"color_B":20},"color_7":{"color_G":254,"color_R":22,"color_B":23},"color_mode":0,"color_8":{"color_G":24,"color_R":25,"color_B":26},"color_0":{"color_G":1,"color_R":1,"color_B":2},"color_1":{"color_G":3,"color_R":4,"color_B":5},"color_2":{"color_G":6,"color_R":7,"color_B":8},"color_3":{"color_G":9,"color_R":10,"color_B":11}},"pump_settings":{"100_degrees":100,"50_degrees":25,"20_degrees":25,"70_degrees":50,"0_degrees":25,"90_degrees":50,"60_degrees":50,"30_degrees":25,"10_degrees":25,"40_degrees":25,"80_degrees":50},"fan_settings":{"100_degrees":1,"50_degrees":60,"20_degrees":60,"70_degrees":80,"0_degrees":60,"90_degrees":100,"60_degrees":70,"30_degrees":60,"10_degrees":60,"40_degrees":60,"80_degrees":90},"id":"762d409-9850-4d47-b25b-1ddf3766c161","nzreal_class_version":4}
1+
{"color_settings":{"color_4":{"color_G":1,"color_R":1,"color_B":1},"color_5":{"color_G":1,"color_R":1,"color_B":1},"color_6":{"color_G":1,"color_R":1,"color_B":1},"color_7":{"color_G":1,"color_R":1,"color_B":1},"color_mode":0,"color_8":{"color_G":1,"color_R":1,"color_B":1},"color_0":{"color_G":1,"color_R":1,"color_B":1},"color_1":{"color_G":1,"color_R":1,"color_B":1},"color_2":{"color_G":1,"color_R":1,"color_B":1},"color_3":{"color_G":1,"color_R":1,"color_B":1}},"pump_settings":{"100_degrees":100,"50_degrees":25,"20_degrees":25,"70_degrees":50,"0_degrees":25,"90_degrees":50,"60_degrees":50,"30_degrees":25,"10_degrees":25,"40_degrees":25,"80_degrees":50},"fan_settings":{"100_degrees":1,"50_degrees":60,"20_degrees":60,"70_degrees":80,"0_degrees":60,"90_degrees":100,"60_degrees":70,"30_degrees":60,"10_degrees":60,"40_degrees":60,"80_degrees":90},"id":"762d409-9850-4d47-b25b-1ddf3766c161","nzreal_class_version":4}

main.nzprofile.test.test.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fan_settings

src/main/java/com/project/pcmr/nzos/json_reader/FileManagement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public void writingFile(String filename, JSONObject JSON_OBJECT) {
202202
* @param filename Nazwa pliku do odczytu.
203203
* @param TEXT Tekst do zapisu.
204204
*/
205-
protected void writingFile(String filename, String TEXT) {
205+
public void writingFile(String filename, String TEXT) {
206206
final String DIR = System.getProperty("user.dir");
207207
try (Writer writer = new BufferedWriter(new OutputStreamWriter(
208208
new FileOutputStream(DIR + "\\" + filename), "utf-8"))) {

src/main/java/com/project/pcmr/nzos/json_reader/InterfaceFileManagment.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,17 @@ interface InterfaceFileManagment<T> {
136136
* @param VALUE Wartość koloru do edycji.
137137
*/
138138
void forceWritingFile(String filename, String OBJECT,String Type, T VALUE);
139+
140+
141+
142+
/**
143+
* Metoda służaca do zapisu pliku.
144+
*
145+
* @param filename Nazwa pliku do odczytu.
146+
* @param TEXT Tekst do zapisu.
147+
*/
148+
void writingFile(String filename, String TEXT);
139149
}
140150

151+
152+

src/main/java/com/project/pcmr/nzos/web_controller/CurrentValueController.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -370,15 +370,7 @@ public List<ArrayList> getColor() {
370370
a8.add(dump[24]);
371371
a8.add(dump[25]);
372372
a8.add(dump[26]);
373-
result.add(a0);
374-
result.add(a1);
375-
result.add(a2);
376-
result.add(a3);
377-
result.add(a4);
378-
result.add(a5);
379-
result.add(a6);
380-
result.add(a7);
381-
result.add(a8);
373+
result.add(a0);result.add(a1);result.add(a2);result.add(a3); result.add(a4);result.add(a5);result.add(a6);result.add(a7); result.add(a8);
382374
return result;
383375
}
384376
}

src/test/java/com/project/pcmr/nzos/json_reader/FileManagementTest.java

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import static org.junit.jupiter.api.Assertions.assertEquals;
1111
import static org.junit.jupiter.api.Assertions.assertNotNull;
12+
import static org.junit.jupiter.api.Assertions.assertNull;
1213

1314
class FileManagementTest {
1415
@Rule
@@ -138,4 +139,68 @@ void arrayToList() {
138139
String Input[] = {"main.nzprofile.test", "fan_settings","_degrees"};
139140
UnitTest1.arrayToList(Input[0],Input[1],Input[2]);
140141
}
142+
143+
144+
@Test
145+
void showLogFile() {
146+
FileManagement<Long> UnitTest1 = new FileManagement<>();
147+
assertNotNull(UnitTest1.showLogFile("app_log.log"));
148+
}
149+
150+
@Test
151+
void forceWritingFile() {
152+
FileManagement<Long> UnitTest1 = new FileManagement<>();
153+
Long testResult = (long)1;
154+
json.put("nzOS", testResult);
155+
String Input[] = {"main.nzprofile.test", "color_settings","color_0","color_G"};
156+
exceptions.expect(IOException.class);
157+
exceptions.expectMessage(("IO exception"));
158+
UnitTest1.forceWritingFile(Input[0], Input[1], testResult);
159+
Long result = UnitTest1.readingFile(Input[0], Input[1],Input[2],Input[3]);
160+
assertEquals(Long.valueOf(testResult), result);
161+
}
162+
163+
@Test
164+
void forceWritingFile1() {
165+
FileManagement<Long> UnitTest1 = new FileManagement<>();
166+
Long testResult = (long)1;
167+
json.put("nzOS", testResult);
168+
String Input[] = {"main.nzprofile.test", "color_settings","color_0","color_G"};
169+
exceptions.expect(IOException.class);
170+
exceptions.expectMessage(("IO exception"));
171+
UnitTest1.forceWritingFile(Input[0], Input[1], "G",testResult);
172+
Long result = UnitTest1.readingFile(Input[0], Input[1],Input[2],Input[3]);
173+
assertEquals(Long.valueOf(testResult), result);
174+
}
175+
176+
177+
@Test
178+
void colorLongArray() {
179+
FileManagement<Long> UnitTest1 = new FileManagement<>();
180+
assertNotNull(UnitTest1.colorLongArray("main.nzprofile.test"));
181+
182+
}
183+
184+
@Test
185+
void arrayToList1() {
186+
FileManagement<Long> UnitTest1 = new FileManagement<>();
187+
String Input[] = {"main.nzprofile.test", "fan_settings","_degrees"};
188+
assertNotNull(UnitTest1.arrayToList(Input[0],Input[1],Input[2]));
189+
}
190+
191+
@Test
192+
void arrayToList2() {
193+
FileManagement<Long> UnitTest1 = new FileManagement<>();
194+
String Input[] = {"main.nzprofile.test", "fan_settings","_degrees"};
195+
assertNotNull(UnitTest1.arrayToList(Input[0],Input[1]));
196+
}
197+
198+
@Test
199+
void writingFile4() {
200+
FileManagement<Long> UnitTest1 = new FileManagement<>();
201+
exceptions.expect(IOException.class);
202+
exceptions.expectMessage(("IO exception"));
203+
UnitTest1.writingFile("main.nzprofile.test.test.test", "fan_settings");
204+
205+
}
141206
}

src/test/java/com/project/pcmr/nzos/management_control/ApiManagmentTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import static org.junit.jupiter.api.Assertions.assertEquals;
88
import static org.junit.jupiter.api.Assertions.assertNotNull;
9+
import static org.junit.jupiter.api.Assertions.assertTrue;
910

1011

1112
class ApiManagmentTest {
@@ -32,6 +33,7 @@ void getCpuTemp() {
3233
@Test
3334
void getCpuTemps() {
3435
ApiManagment UnitTest1 = new ApiManagment();
36+
UnitTest1.getCpuInfo();
3537
assertNotNull(UnitTest1.getCpuTemps());
3638
}
3739

@@ -69,4 +71,12 @@ void theardHelper() {
6971
ApiManagment UnitTest1 = new ApiManagment();
7072
UnitTest1.theardHelper();
7173
}
74+
75+
@Test
76+
void isAdmin() {
77+
exceptions.expect(IllegalAccessError.class);
78+
exceptions.expectMessage(("Problem except for administrator's rights"));
79+
ApiManagment UnitTest1 = new ApiManagment();
80+
assertTrue( UnitTest1.isAdmin());
81+
}
7282
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package com.project.pcmr.nzos.web_controller;
2+
3+
import com.project.pcmr.nzos.json_reader.FileManagement;
4+
import com.project.pcmr.nzos.monitoring.ApiMonitoring;
5+
import org.junit.jupiter.api.BeforeEach;
6+
import org.junit.jupiter.api.Test;
7+
8+
import static org.junit.jupiter.api.Assertions.*;
9+
import static org.junit.jupiter.api.Assertions.assertNotNull;
10+
11+
class CurrentValueTest {
12+
ApiMonitoring start = new ApiMonitoring();
13+
CurrentValue UnitTest1 = new CurrentValue();
14+
@Test
15+
void getPumpSettings() {
16+
assertNotNull(UnitTest1.GetPumpSettings());
17+
}
18+
19+
@Test
20+
void getFanSettings() {
21+
assertNotNull(UnitTest1.GetFanSettings());
22+
}
23+
24+
@Test
25+
void getCVTEMPS() {
26+
assertNotNull(UnitTest1.GetCVTEMPS());
27+
}
28+
29+
@Test
30+
void getCVLOAD() {
31+
assertNotNull(UnitTest1.GetCVLOAD());
32+
}
33+
34+
@Test
35+
void getCVFAN() {
36+
assertNotNull(UnitTest1.GetCVFAN());
37+
}
38+
39+
@Test
40+
void getCVCPUNAME() {
41+
assertNotNull(UnitTest1.getCVCPUNAME());
42+
}
43+
44+
@Test
45+
void getColourPalette() {
46+
assertNotNull(UnitTest1.GetColourPalette());
47+
}
48+
49+
@Test
50+
void getCurrentColorMode() {
51+
assertNotNull(UnitTest1.GetCurrentColorMode());
52+
}
53+
54+
@Test
55+
void getCurrentTemperature() {
56+
assertNotNull(UnitTest1.GetCurrentTemperature());
57+
}
58+
59+
@Test
60+
void getCurrentFanSpeed() {
61+
assertNotNull(UnitTest1.GetCurrentFanSpeed());
62+
}
63+
64+
@Test
65+
void getCurrentLiquidTemp() {
66+
assertNotNull(UnitTest1.GetCurrentLiquidTemp());
67+
}
68+
69+
@Test
70+
void getCurrentSetFanSpeed() {
71+
assertNotNull(UnitTest1.GetCurrentSetFanSpeed());
72+
}
73+
74+
@Test
75+
void getCurrentSetPumpSpeed() {
76+
assertNotNull(UnitTest1.GetCurrentSetPumpSpeed());
77+
}
78+
79+
@Test
80+
void getCurrentProtocolVer() {
81+
assertNotNull(UnitTest1.GetCurrentProtocolVer());
82+
}
83+
84+
@Test
85+
void getCurrentSafeCode() {
86+
assertNotNull(UnitTest1.GetCurrentSafeCode());
87+
}
88+
89+
@Test
90+
void getWarningTemperature() {
91+
assertNotNull(UnitTest1.GetWarningTemperature());
92+
}
93+
94+
@BeforeEach
95+
void setUp() {
96+
start.startTheard();
97+
}
98+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
package com.project.pcmr.nzos.web_controller;
22

3+
import org.junit.Rule;
34
import org.junit.jupiter.api.Test;
5+
import org.junit.rules.ExpectedException;
6+
7+
import java.io.IOException;
48

59

610
class NzOsApplicationTest {
711

12+
@Rule
13+
public final ExpectedException exceptions = ExpectedException.none();
14+
15+
816
@Test
917
void main() {
18+
exceptions.expect(IOException .class);
19+
exceptions.expectMessage(("IO exception"));
20+
return;
1021
}
22+
1123
}

0 commit comments

Comments
 (0)