1+ package checkmarx .ast .eclipse .plugin .tests .unit .views ;
2+
3+ import static org .junit .jupiter .api .Assertions .*;
4+ import org .junit .jupiter .api .Test ;
5+ import org .mockito .MockedStatic ;
6+ import org .mockito .Mockito ;
7+ import com .checkmarx .eclipse .views .GlobalSettings ;
8+ import com .checkmarx .eclipse .views .filters .FilterState ;
9+
10+ class GlobalSettingsTest {
11+
12+ @ Test
13+ void testSetAndGetProjectId () {
14+
15+ GlobalSettings settings = new GlobalSettings ();
16+
17+ settings .setProjectId ("project1" );
18+
19+ assertEquals ("project1" , settings .getProjectId ());
20+ }
21+
22+ @ Test
23+ void testSetAndGetBranch () {
24+
25+ GlobalSettings settings = new GlobalSettings ();
26+
27+ settings .setBranch ("main" );
28+
29+ assertEquals ("main" , settings .getBranch ());
30+ }
31+
32+ @ Test
33+ void testSetAndGetScanId () {
34+
35+ GlobalSettings settings = new GlobalSettings ();
36+
37+ settings .setScanId ("scan123" );
38+
39+ assertEquals ("scan123" , settings .getScanId ());
40+ }
41+
42+ @ Test
43+ void testStoreInPreferencesDoesNotThrow () {
44+
45+ assertDoesNotThrow (() ->
46+ GlobalSettings .storeInPreferences ("test-key" , "test-value" )
47+ );
48+ }
49+
50+ @ Test
51+ void testGetFromPreferencesReturnsValue () {
52+
53+ String value = GlobalSettings .getFromPreferences ("non-existing" , "default" );
54+
55+ assertNotNull (value );
56+ }
57+
58+ @ Test
59+ void testLoadSettings () {
60+
61+ GlobalSettings settings = new GlobalSettings ();
62+
63+ try (MockedStatic <FilterState > filterMock = Mockito .mockStatic (FilterState .class )) {
64+
65+ settings .loadSettings ();
66+
67+ filterMock .verify (FilterState ::loadFiltersFromSettings );
68+ }
69+
70+ assertNotNull (settings .getProjectId ());
71+ assertNotNull (settings .getBranch ());
72+ assertNotNull (settings .getScanId ());
73+ }
74+ }
0 commit comments