+ * Note: you may also choose to call {@link Mockito}.mock directly if you do not + * want to reset all of the mocks. + */ + public void reset() throws Exception { + mockedApps.clear(); + Mockito.reset(provider); + } + + public MockAppBuilder builder() { + return new MockAppBuilder(this); + } + + public static class MockAppBuilder { + public final SpringBootApp app = mock(SpringBootApp.class); + private MockRunningAppProvider runningAppProvider; + + public MockAppBuilder(MockRunningAppProvider runningAppProvider) { + this.runningAppProvider = runningAppProvider; + } + + public MockAppBuilder enviroment(String env) throws Exception { + when(app.getEnvironment()).thenReturn(env); + return this; + } + + public MockAppBuilder beans(String beans) throws Exception { + when(app.getBeans()).thenReturn(beans); + return this; + } + + public MockAppBuilder processId(String processId) { + when(app.getProcessID()).thenReturn(processId); + return this; + } + + public MockAppBuilder processName(String name) { + when(app.getProcessName()).thenReturn(name); + return this; + } + + public MockAppBuilder port(String port) throws Exception { + when(app.getPort()).thenReturn(port); + return this; + } + + public MockAppBuilder isSpringBootApp(boolean isBoot) throws Exception { + when(app.isSpringBootApp()).thenReturn(isBoot); + return this; + } + + public MockAppBuilder containsLanguageServerProcessPropery(boolean hasProperty) { + when(app.containsSystemProperty(BootJavaLanguageServer.LANGUAGE_SERVER_PROCESS_PROPERTY)) + .thenReturn(hasProperty); + return this; + } + + public MockAppBuilder getRequestMappings(String mappings) throws Exception { + when(app.getRequestMappings()).thenReturn(mappings); + return this; + } + + public void build() { + runningAppProvider.mockedApps.add(app); + } + + } +}