Merge branch 'master' into 2.0.x
This commit is contained in:
@@ -89,7 +89,7 @@ public class FeaturesEndpoint
|
||||
type.getPackage().getImplementationVendor()));
|
||||
}
|
||||
|
||||
class Features {
|
||||
static class Features {
|
||||
final List<Feature> enabled = new ArrayList<>();
|
||||
final List<String> disabled = new ArrayList<>();
|
||||
|
||||
@@ -103,13 +103,13 @@ public class FeaturesEndpoint
|
||||
}
|
||||
|
||||
|
||||
class Feature {
|
||||
static class Feature {
|
||||
final String type;
|
||||
final String name;
|
||||
final String version;
|
||||
final String vendor;
|
||||
|
||||
public Feature(String type, String name, String version, String vendor) {
|
||||
public Feature(String name, String type, String version, String vendor) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
this.version = version;
|
||||
@@ -131,5 +131,37 @@ public class FeaturesEndpoint
|
||||
public String getVendor() {
|
||||
return vendor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Feature{" +
|
||||
"type='" + type + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", version='" + version + '\'' +
|
||||
", vendor='" + vendor + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Feature feature = (Feature) o;
|
||||
|
||||
if (type != null ? !type.equals(feature.type) : feature.type != null) return false;
|
||||
if (name != null ? !name.equals(feature.name) : feature.name != null) return false;
|
||||
if (version != null ? !version.equals(feature.version) : feature.version != null) return false;
|
||||
return vendor != null ? vendor.equals(feature.vendor) : feature.vendor == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = type != null ? type.hashCode() : 0;
|
||||
result = 31 * result + (name != null ? name.hashCode() : 0);
|
||||
result = 31 * result + (version != null ? version.hashCode() : 0);
|
||||
result = 31 * result + (vendor != null ? vendor.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,10 +13,8 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
@@ -44,9 +42,14 @@ public class FeaturesEndpointTests {
|
||||
public void invokeWorks() {
|
||||
FeaturesEndpoint.Features features = this.context.getBean(FeaturesEndpoint.class)
|
||||
.features();
|
||||
assertThat(features, is(notNullValue()));
|
||||
assertThat(features.getEnabled().size(), is(equalTo(2)));
|
||||
assertThat(features.getDisabled().size(), is(equalTo(1)));
|
||||
assertThat(features).isNotNull();
|
||||
assertThat(features.getEnabled()).hasSize(2)
|
||||
.contains(newFeature("foo", Foo.class), newFeature("Baz Feature", Baz.class));
|
||||
assertThat(features.getDisabled()).hasSize(1).contains("Bar");
|
||||
}
|
||||
|
||||
private FeaturesEndpoint.Feature newFeature(String name, Class<?> type) {
|
||||
return new FeaturesEndpoint.Feature(name, type.getCanonicalName(), null, null);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@@ -60,7 +63,7 @@ public class FeaturesEndpointTests {
|
||||
HasFeatures localFeatures() {
|
||||
HasFeatures features = HasFeatures.namedFeatures(
|
||||
new NamedFeature("foo", Foo.class),
|
||||
new NamedFeature("Bar Feature", Bar.class));
|
||||
new NamedFeature("Baz Feature", Baz.class));
|
||||
features.getAbstractFeatures().add(Bar.class);
|
||||
return features;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user