Skip to content

Commit ec90b87

Browse files
committed
Add javadoc to mock boundary classes
1 parent 724bb37 commit ec90b87

12 files changed

+132
-0
lines changed

src/test/java/org/hydev/mcpm/client/arguments/mock/MockExportBoundary.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import java.util.ArrayList;
88
import java.util.List;
99

10+
/**
11+
* Provides a mock implementation of the ExportPluginsBoundary interface for testing.
12+
*/
1013
public class MockExportBoundary implements ExportPluginsBoundary {
1114
private final List<ExportPluginsInput> inputs = new ArrayList<>();
1215

@@ -19,10 +22,20 @@ public ExportPluginsResult export(ExportPluginsInput input) {
1922
return new ExportPluginsResult(defaultResult);
2023
}
2124

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+
*/
2230
public void setDefaultResult(ExportPluginsResult.State defaultResult) {
2331
this.defaultResult = defaultResult;
2432
}
2533

34+
/**
35+
* Gets a list of all inputs that this interface was invoked with.
36+
*
37+
* @return A list of input objects.
38+
*/
2639
public List<ExportPluginsInput> getInputs() {
2740
return List.copyOf(inputs);
2841
}

src/test/java/org/hydev/mcpm/client/arguments/mock/MockInstallBoundary.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
import java.util.ArrayList;
99
import java.util.List;
1010

11+
/**
12+
* Provides a mock implementation of the InstallBoundary interface for testing.
13+
*/
1114
public class MockInstallBoundary implements InstallBoundary {
1215
private final List<InstallInput> inputs = new ArrayList<>();
1316

@@ -18,6 +21,11 @@ public List<InstallResult> installPlugin(InstallInput installInput) {
1821
return List.of(new InstallResult(InstallResult.Type.SUCCESS_INSTALLED, installInput.name()));
1922
}
2023

24+
/**
25+
* Gets a list of all inputs that this interface was invoked with.
26+
*
27+
* @return A list of input objects.
28+
*/
2129
public List<InstallInput> getInputs() {
2230
return List.copyOf(inputs);
2331
}

src/test/java/org/hydev/mcpm/client/arguments/mock/MockListBoundary.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
import java.util.ArrayList;
99
import java.util.List;
1010

11+
/**
12+
* Provides a mock implementation of the ListAllBoundary interface for testing.
13+
*/
1114
public class MockListBoundary implements ListAllBoundary {
1215
private final List<ListType> types = new ArrayList<>();
1316

@@ -18,6 +21,11 @@ public List<PluginYml> listAll(ListType parameter) {
1821
return List.of();
1922
}
2023

24+
/**
25+
* Gets a list of all types that this interface was invoked with.
26+
*
27+
* @return A list of type objects.
28+
*/
2129
public List<ListType> getTypes() {
2230
return List.copyOf(types);
2331
}

src/test/java/org/hydev/mcpm/client/arguments/mock/MockLoadBoundary.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import java.util.ArrayList;
88
import java.util.List;
99

10+
/**
11+
* Provides a mock implementation of the LoadBoundary interface for testing.
12+
*/
1013
public class MockLoadBoundary implements LoadBoundary {
1114
private final List<String> names = new ArrayList<>();
1215

@@ -24,14 +27,29 @@ public boolean loadPlugin(String name) throws PluginNotFoundException {
2427
return defaultResult;
2528
}
2629

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+
*/
2735
public void setDefaultResult(boolean result) {
2836
this.defaultResult = result;
2937
}
3038

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+
*/
3144
public void setThrowsNotFound(boolean notFound) {
3245
this.throwsNotFound = notFound;
3346
}
3447

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+
*/
3553
public List<String> getNames() {
3654
return List.copyOf(names);
3755
}

src/test/java/org/hydev/mcpm/client/arguments/mock/MockMirrorBoundary.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
import java.util.Set;
1111
import java.util.stream.IntStream;
1212

13+
/**
14+
* Provides a mock implementation of the MirrorSelectBoundary class.
15+
*/
1316
public class MockMirrorBoundary implements MirrorSelectBoundary {
1417
private Mirror selected;
1518
private final List<Mirror> mirrors;
@@ -23,6 +26,12 @@ public MockMirrorBoundary(List<Mirror> mirrors) {
2326
this.selected = mirrors.stream().findFirst().orElse(null);
2427
}
2528

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+
*/
2635
public static Mirror mockMirror(String host) {
2736
return new Mirror(
2837
host,
@@ -87,14 +96,29 @@ public void setSelectedMirror(Mirror mirror) throws IOException {
8796
selected = mirror;
8897
}
8998

99+
/**
100+
* Gets if the mock mirrors object was udpated.
101+
*
102+
* @return True if the updateMirrors method was invoked at least once.
103+
*/
90104
public boolean getDidUpdateMirrors() {
91105
return didUpdateMirrors;
92106
}
93107

108+
/**
109+
* Gets if the mirrors were pinged.
110+
*
111+
* @return True if the pingMirrors object was invoked at least once.
112+
*/
94113
public boolean getDidPingMirrors() {
95114
return didPingMirrors;
96115
}
97116

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+
*/
98122
public void setThrowsIOException(boolean value) {
99123
throwsIOException = value;
100124
}

src/test/java/org/hydev/mcpm/client/arguments/mock/MockPageController.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
import org.hydev.mcpm.client.commands.presenters.PagedPresenter;
55
import org.jetbrains.annotations.Nullable;
66

7+
/**
8+
* Provides a mock implementation of the PageBoundary interface for testing.
9+
*/
710
public class MockPageController implements PageBoundary {
811
@Override
912
public int pageSize() {

src/test/java/org/hydev/mcpm/client/arguments/mock/MockRefreshFetcher.java

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

88
import java.util.List;
99

10+
/**
11+
* Provides a mock implementation of the DatabaseFetcher interface for testing RefreshController.
12+
*/
1013
public class MockRefreshFetcher implements DatabaseFetcher {
1114
private boolean fetched = false;
1215

@@ -25,6 +28,11 @@ public boolean getFetched() {
2528
return fetched;
2629
}
2730

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+
*/
2836
public void setDefaultResult(@Nullable Database database) {
2937
this.defaultResult = database;
3038
}

src/test/java/org/hydev/mcpm/client/arguments/mock/MockReloadBoundary.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
import java.util.List;
77
import java.util.ArrayList;
88

9+
/**
10+
* Provides a mock implementation of the ReloadBoundary interface for testing.
11+
*/
912
public class MockReloadBoundary implements ReloadBoundary {
1013
private final List<String> names = new ArrayList<>();
1114

@@ -20,10 +23,20 @@ public void reloadPlugin(String name) throws PluginNotFoundException {
2023
}
2124
}
2225

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+
*/
2331
public void setThrowsNotFound(boolean notFound) {
2432
this.throwsNotFound = notFound;
2533
}
2634

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+
*/
2740
public List<String> getNames() {
2841
return List.copyOf(names);
2942
}

src/test/java/org/hydev/mcpm/client/arguments/mock/MockSearchBoundary.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import java.util.ArrayList;
88
import java.util.List;
99

10+
/**
11+
* Provides a mock implementation of the SearchBoundary interface for testing.
12+
*/
1013
public class MockSearchBoundary implements SearchPackagesBoundary {
1114
private final List<SearchPackagesInput> inputs = new ArrayList<>();
1215

@@ -17,6 +20,11 @@ public SearchPackagesResult search(SearchPackagesInput input) {
1720
return SearchPackagesResult.by(SearchPackagesResult.State.SUCCESS);
1821
}
1922

23+
/**
24+
* Gets a list of all inputs that this interface was invoked with.
25+
*
26+
* @return A list of input objects.
27+
*/
2028
public List<SearchPackagesInput> getInputs() {
2129
return List.copyOf(inputs);
2230
}

src/test/java/org/hydev/mcpm/client/arguments/mock/MockUninstallBoundary.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import java.util.ArrayList;
88
import java.util.List;
99

10+
/**
11+
* Provides a mock implementation of the UninstallBoundary interface for testing.
12+
*/
1013
public class MockUninstallBoundary implements UninstallBoundary {
1114
private final List<UninstallInput> inputs = new ArrayList<>();
1215
private UninstallResult.State defaultState = UninstallResult.State.SUCCESS;
@@ -29,6 +32,11 @@ public void setDefaultState(UninstallResult.State state) {
2932
defaultState = state;
3033
}
3134

35+
/**
36+
* Gets a list of all inputs that this interface was invoked with.
37+
*
38+
* @return A list of input objects.
39+
*/
3240
public List<UninstallInput> getInputs() {
3341
return List.copyOf(inputs);
3442
}

0 commit comments

Comments
 (0)