Some more cleanups to CF editor test
Extracted mock cf client config for (hopefully) easier reuse
This commit is contained in:
@@ -28,24 +28,18 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFBuildpack;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFDomain;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFServiceInstance;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFStack;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.ClientRequests;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CloudFoundryClientFactory;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.ClientParamsProvider;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.NoTargetsException;
|
||||
import org.springframework.ide.vscode.commons.languageserver.config.LanguageServerInitializer;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.util.Unicodes;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.CodeAction;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.Editor;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness;
|
||||
import org.springframework.ide.vscode.manifest.yaml.annotations.ManifestLanguageServerTest;
|
||||
import org.springframework.ide.vscode.manifest.yaml.bootiful.ManifestLanguageServerTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -57,44 +51,10 @@ public class ManifestYamlEditorTest {
|
||||
@Autowired
|
||||
MockCloudfoundry cloudfoundry;
|
||||
|
||||
@Autowired
|
||||
SimpleLanguageServer server;
|
||||
|
||||
@Autowired
|
||||
LanguageServerInitializer serverInit;
|
||||
|
||||
@Autowired
|
||||
LanguageServerHarness<SimpleLanguageServer> harness;
|
||||
|
||||
|
||||
@TestConfiguration
|
||||
public static class MockCloudfoundryConfiguration {
|
||||
|
||||
@Bean public MockCloudfoundry cloudfoundry() {
|
||||
return new MockCloudfoundry();
|
||||
}
|
||||
|
||||
@Bean public CloudFoundryClientFactory cloudfoundryClientFactory(MockCloudfoundry cf) {
|
||||
return cf.factory;
|
||||
}
|
||||
|
||||
@Bean public ClientParamsProvider cloudfoundryParams(MockCloudfoundry cf) {
|
||||
return cf.defaultParamsProvider;
|
||||
}
|
||||
|
||||
@Bean public LanguageServerHarness<SimpleLanguageServer> harness(SimpleLanguageServer server) throws Exception {
|
||||
LanguageServerHarness<SimpleLanguageServer> harness = new LanguageServerHarness<>(
|
||||
()-> server,
|
||||
LanguageId.CF_MANIFEST
|
||||
);
|
||||
harness.intialize(null);
|
||||
System.setProperty("lsp.yaml.completions.errors.disable", "false");
|
||||
return harness;
|
||||
}
|
||||
}
|
||||
|
||||
@Test public void testReconcileCatchesParseError() throws Exception {
|
||||
|
||||
Editor editor = harness.newEditor(
|
||||
"somemap: val\n"+
|
||||
"- sequence"
|
||||
@@ -105,9 +65,6 @@ public class ManifestYamlEditorTest {
|
||||
}
|
||||
|
||||
@Test public void reconcileRunsOnDocumentOpenAndChange() throws Exception {
|
||||
// LanguageServerHarness harness = new LanguageServerHarness(ManifestYamlLanguageServerInitializer::new, LanguageId.CF_MANIFEST);
|
||||
// harness.intialize(null);
|
||||
|
||||
Editor editor = harness.newEditor(
|
||||
"somemap: val\n"+
|
||||
"- sequence"
|
||||
|
||||
@@ -50,7 +50,7 @@ public class MockCloudfoundry {
|
||||
/**
|
||||
* Reset the mocks. Use this if the default's programmed into the mocks don't suite your test case.
|
||||
* <p>
|
||||
* Note: you may also choose to call {@link Mockito}.mock directly if you do not want to
|
||||
* Note: you may also choose to call {@link Mockito}.reset directly if you do not want to
|
||||
* reset all of the mocks.
|
||||
*/
|
||||
public void reset() throws Exception {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.manifest.yaml.annotations;
|
||||
package org.springframework.ide.vscode.manifest.yaml.bootiful;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -24,7 +24,10 @@ import org.springframework.test.annotation.DirtiesContext.ClassMode;
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@OverrideAutoConfiguration(enabled=false)
|
||||
@ImportAutoConfiguration(classes=LanguageServerAutoConf.class)
|
||||
@SpringBootTest(classes=ManifestYamlLanguageServerBootApp.class)
|
||||
@SpringBootTest(classes={
|
||||
ManifestYamlLanguageServerBootApp.class,
|
||||
ManifestYamlLanguageServerTestConfiguration.class
|
||||
})
|
||||
@DirtiesContext(classMode=ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
public @interface ManifestLanguageServerTest {
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.manifest.yaml.bootiful;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CloudFoundryClientFactory;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.ClientParamsProvider;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness;
|
||||
import org.springframework.ide.vscode.manifest.yaml.MockCloudfoundry;
|
||||
|
||||
@Configuration
|
||||
public class ManifestYamlLanguageServerTestConfiguration {
|
||||
|
||||
@Bean public MockCloudfoundry cloudfoundry() {
|
||||
return new MockCloudfoundry();
|
||||
}
|
||||
|
||||
@Bean public CloudFoundryClientFactory cloudfoundryClientFactory(MockCloudfoundry cf) {
|
||||
return cf.factory;
|
||||
}
|
||||
|
||||
@Bean public ClientParamsProvider cloudfoundryParams(MockCloudfoundry cf) {
|
||||
return cf.defaultParamsProvider;
|
||||
}
|
||||
|
||||
@Bean public LanguageServerHarness<SimpleLanguageServer> harness(SimpleLanguageServer server) throws Exception {
|
||||
LanguageServerHarness<SimpleLanguageServer> harness = new LanguageServerHarness<>(
|
||||
()-> server,
|
||||
LanguageId.CF_MANIFEST
|
||||
);
|
||||
harness.intialize(null);
|
||||
System.setProperty("lsp.yaml.completions.errors.disable", "false"); //Yuck! Do we really need this??
|
||||
return harness;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user