File tree Expand file tree Collapse file tree 12 files changed +132
-0
lines changed
src/test/java/org/hydev/mcpm/client/arguments/mock Expand file tree Collapse file tree 12 files changed +132
-0
lines changed Original file line number Diff line number Diff line change 7
7
import java .util .ArrayList ;
8
8
import java .util .List ;
9
9
10
+ /**
11
+ * Provides a mock implementation of the ExportPluginsBoundary interface for testing.
12
+ */
10
13
public class MockExportBoundary implements ExportPluginsBoundary {
11
14
private final List <ExportPluginsInput > inputs = new ArrayList <>();
12
15
@@ -19,10 +22,20 @@ public ExportPluginsResult export(ExportPluginsInput input) {
19
22
return new ExportPluginsResult (defaultResult );
20
23
}
21
24
25
+ /**
26
+ * Sets the default result that this interface will return when invoked.
27
+ *
28
+ * @param defaultResult The default return value for the export method.
29
+ */
22
30
public void setDefaultResult (ExportPluginsResult .State defaultResult ) {
23
31
this .defaultResult = defaultResult ;
24
32
}
25
33
34
+ /**
35
+ * Gets a list of all inputs that this interface was invoked with.
36
+ *
37
+ * @return A list of input objects.
38
+ */
26
39
public List <ExportPluginsInput > getInputs () {
27
40
return List .copyOf (inputs );
28
41
}
Original file line number Diff line number Diff line change 8
8
import java .util .ArrayList ;
9
9
import java .util .List ;
10
10
11
+ /**
12
+ * Provides a mock implementation of the InstallBoundary interface for testing.
13
+ */
11
14
public class MockInstallBoundary implements InstallBoundary {
12
15
private final List <InstallInput > inputs = new ArrayList <>();
13
16
@@ -18,6 +21,11 @@ public List<InstallResult> installPlugin(InstallInput installInput) {
18
21
return List .of (new InstallResult (InstallResult .Type .SUCCESS_INSTALLED , installInput .name ()));
19
22
}
20
23
24
+ /**
25
+ * Gets a list of all inputs that this interface was invoked with.
26
+ *
27
+ * @return A list of input objects.
28
+ */
21
29
public List <InstallInput > getInputs () {
22
30
return List .copyOf (inputs );
23
31
}
Original file line number Diff line number Diff line change 8
8
import java .util .ArrayList ;
9
9
import java .util .List ;
10
10
11
+ /**
12
+ * Provides a mock implementation of the ListAllBoundary interface for testing.
13
+ */
11
14
public class MockListBoundary implements ListAllBoundary {
12
15
private final List <ListType > types = new ArrayList <>();
13
16
@@ -18,6 +21,11 @@ public List<PluginYml> listAll(ListType parameter) {
18
21
return List .of ();
19
22
}
20
23
24
+ /**
25
+ * Gets a list of all types that this interface was invoked with.
26
+ *
27
+ * @return A list of type objects.
28
+ */
21
29
public List <ListType > getTypes () {
22
30
return List .copyOf (types );
23
31
}
Original file line number Diff line number Diff line change 7
7
import java .util .ArrayList ;
8
8
import java .util .List ;
9
9
10
+ /**
11
+ * Provides a mock implementation of the LoadBoundary interface for testing.
12
+ */
10
13
public class MockLoadBoundary implements LoadBoundary {
11
14
private final List <String > names = new ArrayList <>();
12
15
@@ -24,14 +27,29 @@ public boolean loadPlugin(String name) throws PluginNotFoundException {
24
27
return defaultResult ;
25
28
}
26
29
30
+ /**
31
+ * Sets the default result that this interface will return when invoked.
32
+ *
33
+ * @param result The default return value for the load method.
34
+ */
27
35
public void setDefaultResult (boolean result ) {
28
36
this .defaultResult = result ;
29
37
}
30
38
39
+ /**
40
+ * Sets whether this interface should throw an exception when invoked.
41
+ *
42
+ * @param notFound If true, this interface will throw an exception on invocation.
43
+ */
31
44
public void setThrowsNotFound (boolean notFound ) {
32
45
this .throwsNotFound = notFound ;
33
46
}
34
47
48
+ /**
49
+ * Gets a list of all names that this interface was invoked with.
50
+ *
51
+ * @return A list of strings that represent plugin names.
52
+ */
35
53
public List <String > getNames () {
36
54
return List .copyOf (names );
37
55
}
Original file line number Diff line number Diff line change 10
10
import java .util .Set ;
11
11
import java .util .stream .IntStream ;
12
12
13
+ /**
14
+ * Provides a mock implementation of the MirrorSelectBoundary class.
15
+ */
13
16
public class MockMirrorBoundary implements MirrorSelectBoundary {
14
17
private Mirror selected ;
15
18
private final List <Mirror > mirrors ;
@@ -23,6 +26,12 @@ public MockMirrorBoundary(List<Mirror> mirrors) {
23
26
this .selected = mirrors .stream ().findFirst ().orElse (null );
24
27
}
25
28
29
+ /**
30
+ * Creates a mock Mirror object to pass to this object.
31
+ *
32
+ * @param host The provided host that will be used in the mirror initialzation.
33
+ * @return A Mirror object.
34
+ */
26
35
public static Mirror mockMirror (String host ) {
27
36
return new Mirror (
28
37
host ,
@@ -87,14 +96,29 @@ public void setSelectedMirror(Mirror mirror) throws IOException {
87
96
selected = mirror ;
88
97
}
89
98
99
+ /**
100
+ * Gets if the mock mirrors object was udpated.
101
+ *
102
+ * @return True if the updateMirrors method was invoked at least once.
103
+ */
90
104
public boolean getDidUpdateMirrors () {
91
105
return didUpdateMirrors ;
92
106
}
93
107
108
+ /**
109
+ * Gets if the mirrors were pinged.
110
+ *
111
+ * @return True if the pingMirrors object was invoked at least once.
112
+ */
94
113
public boolean getDidPingMirrors () {
95
114
return didPingMirrors ;
96
115
}
97
116
117
+ /**
118
+ * Sets if the methods will throw an exception.
119
+ *
120
+ * @param value If true, every boundary method that can throw an IOException will throw one.
121
+ */
98
122
public void setThrowsIOException (boolean value ) {
99
123
throwsIOException = value ;
100
124
}
Original file line number Diff line number Diff line change 4
4
import org .hydev .mcpm .client .commands .presenters .PagedPresenter ;
5
5
import org .jetbrains .annotations .Nullable ;
6
6
7
+ /**
8
+ * Provides a mock implementation of the PageBoundary interface for testing.
9
+ */
7
10
public class MockPageController implements PageBoundary {
8
11
@ Override
9
12
public int pageSize () {
Original file line number Diff line number Diff line change 7
7
8
8
import java .util .List ;
9
9
10
+ /**
11
+ * Provides a mock implementation of the DatabaseFetcher interface for testing RefreshController.
12
+ */
10
13
public class MockRefreshFetcher implements DatabaseFetcher {
11
14
private boolean fetched = false ;
12
15
@@ -25,6 +28,11 @@ public boolean getFetched() {
25
28
return fetched ;
26
29
}
27
30
31
+ /**
32
+ * Sets the default database result that this interface will return when invoked.
33
+ *
34
+ * @param database The default return value for the load method.
35
+ */
28
36
public void setDefaultResult (@ Nullable Database database ) {
29
37
this .defaultResult = database ;
30
38
}
Original file line number Diff line number Diff line change 6
6
import java .util .List ;
7
7
import java .util .ArrayList ;
8
8
9
+ /**
10
+ * Provides a mock implementation of the ReloadBoundary interface for testing.
11
+ */
9
12
public class MockReloadBoundary implements ReloadBoundary {
10
13
private final List <String > names = new ArrayList <>();
11
14
@@ -20,10 +23,20 @@ public void reloadPlugin(String name) throws PluginNotFoundException {
20
23
}
21
24
}
22
25
26
+ /**
27
+ * Sets whether this interface should throw an exception when invoked.
28
+ *
29
+ * @param notFound If true, this interface will throw an exception on invocation.
30
+ */
23
31
public void setThrowsNotFound (boolean notFound ) {
24
32
this .throwsNotFound = notFound ;
25
33
}
26
34
35
+ /**
36
+ * Gets a list of all names that this interface was invoked with.
37
+ *
38
+ * @return A list of strings that represent plugin names.
39
+ */
27
40
public List <String > getNames () {
28
41
return List .copyOf (names );
29
42
}
Original file line number Diff line number Diff line change 7
7
import java .util .ArrayList ;
8
8
import java .util .List ;
9
9
10
+ /**
11
+ * Provides a mock implementation of the SearchBoundary interface for testing.
12
+ */
10
13
public class MockSearchBoundary implements SearchPackagesBoundary {
11
14
private final List <SearchPackagesInput > inputs = new ArrayList <>();
12
15
@@ -17,6 +20,11 @@ public SearchPackagesResult search(SearchPackagesInput input) {
17
20
return SearchPackagesResult .by (SearchPackagesResult .State .SUCCESS );
18
21
}
19
22
23
+ /**
24
+ * Gets a list of all inputs that this interface was invoked with.
25
+ *
26
+ * @return A list of input objects.
27
+ */
20
28
public List <SearchPackagesInput > getInputs () {
21
29
return List .copyOf (inputs );
22
30
}
Original file line number Diff line number Diff line change 7
7
import java .util .ArrayList ;
8
8
import java .util .List ;
9
9
10
+ /**
11
+ * Provides a mock implementation of the UninstallBoundary interface for testing.
12
+ */
10
13
public class MockUninstallBoundary implements UninstallBoundary {
11
14
private final List <UninstallInput > inputs = new ArrayList <>();
12
15
private UninstallResult .State defaultState = UninstallResult .State .SUCCESS ;
@@ -29,6 +32,11 @@ public void setDefaultState(UninstallResult.State state) {
29
32
defaultState = state ;
30
33
}
31
34
35
+ /**
36
+ * Gets a list of all inputs that this interface was invoked with.
37
+ *
38
+ * @return A list of input objects.
39
+ */
32
40
public List <UninstallInput > getInputs () {
33
41
return List .copyOf (inputs );
34
42
}
You can’t perform that action at this time.
0 commit comments