Start adding some tests for 'InjectedInto' hover provider

This commit is contained in:
Kris De Volder
2017-10-27 13:19:41 -07:00
parent c7c1ddc692
commit fc9c84f58f
9 changed files with 424 additions and 31 deletions

View File

@@ -188,12 +188,14 @@ public class SpringBootApp {
return null;
}
public LiveBeansModel getBeans() throws Exception {
String json = getBeansJson();
if (StringUtil.hasText(json)) {
public LiveBeansModel getBeans() {
try {
String json = getBeansJson();
return LiveBeansModel.parse(json);
} catch (Exception e) {
Log.log(e);
return LiveBeansModel.builder().build();
}
return null;
}
public String getRequestMappings() throws Exception {

View File

@@ -10,8 +10,7 @@
*******************************************************************************/
package org.springframework.ide.vscode.commons.boot.app.cli.livebean;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.Arrays;
/**
* @author Martin Lippert
@@ -26,6 +25,34 @@ public class LiveBean {
private final String resource;
private final String[] dependencies;
public static class Builder {
private String id;
private String[] aliases = {};
private String scope;
private String type;
private String resource;
private String[] dependencies = {};
public LiveBean build() {
return new LiveBean(id, aliases, scope, type, resource, dependencies);
}
public Builder id(String id) {
this.id = id;
return this;
}
public Builder type(String type) {
this.type = type;
return this;
}
public Builder dependencies(String... deps) {
this.dependencies = deps;
return this;
}
}
protected LiveBean(String id, String[] aliases, String scope, String type, String resource, String[] dependencies) {
super();
this.id = id;
@@ -60,4 +87,13 @@ public class LiveBean {
return dependencies;
}
@Override
public String toString() {
return "LiveBean [id=" + id + ", type=" + type + ", dependencies=" + Arrays.toString(dependencies) + "]";
}
public static Builder builder() {
return new Builder();
}
}

View File

@@ -40,7 +40,7 @@ public class LiveBeansModel {
return new LiveBeansModel(beansViaName.build(), beansViaType.build(), beansViaDependency.build());
}
public void add(LiveBean bean) {
public Builder add(LiveBean bean) {
String type = bean.getType();
if (type != null) {
beansViaType.put(type, bean);
@@ -57,6 +57,7 @@ public class LiveBeansModel {
beansViaDependency.put(dep, bean);
}
}
return this;
}
}