本文整理汇总了Java中org.springframework.boot.actuate.info.Info类的典型用法代码示例。如果您正苦于以下问题:Java Info类的具体用法?Java Info怎么用?Java Info使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Info类属于org.springframework.boot.actuate.info包,在下文中一共展示了Info类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldAddBuildInfoToBuilder
import org.springframework.boot.actuate.info.Info; //导入依赖的package包/类
@Test
public void shouldAddBuildInfoToBuilder() throws Exception {
DmBuildInfo dmBuildInfo = new DmBuildInfo("name","env","project");
Info.Builder builder = new Info.Builder();
dmBuildInfo.contribute(builder);
Map<String,Object> buildInfo = new HashMap<>();
buildInfo.put("environment", "env");
buildInfo.put("project", "project");
buildInfo.put("name", "name");
buildInfo.put("version", "unknown");
buildInfo.put("date", "unknown");
buildInfo.put("commit", "unknown");
buildInfo.put("extra", Collections.EMPTY_MAP);
Map<String,Object> map = new HashMap<>();
map.put("buildInfo",buildInfo);
Info info = builder.build();
assertThat(info.getDetails(), CoreMatchers.equalTo(map));
}
示例2: shouldAddBuildInfoToBuilderNullBuildInfo
import org.springframework.boot.actuate.info.Info; //导入依赖的package包/类
@Test
public void shouldAddBuildInfoToBuilderNullBuildInfo() throws Exception {
DmBuildInfo dmBuildInfo = new DmBuildInfo("name","env","project",null);
Info.Builder builder = new Info.Builder();
dmBuildInfo.contribute(builder);
Map<String,Object> buildInfo = new HashMap<>();
buildInfo.put("environment", "env");
buildInfo.put("project", "project");
buildInfo.put("name", "name");
buildInfo.put("version", "unknown");
buildInfo.put("date", "unknown");
buildInfo.put("commit", "unknown");
buildInfo.put("extra", Collections.EMPTY_MAP);
Map<String,Object> map = new HashMap<>();
map.put("buildInfo",buildInfo);
Info info = builder.build();
assertThat(info.getDetails(), CoreMatchers.equalTo(map));
}
示例3: shouldAddBuildInfoToBuilderIncludesBuildNumber
import org.springframework.boot.actuate.info.Info; //导入依赖的package包/类
@Test
public void shouldAddBuildInfoToBuilderIncludesBuildNumber() throws Exception {
DmBuildInfo dmBuildInfo = new DmBuildInfo("name","env","project",BUILD_INFO_WITH_BUILD_NO);
Info.Builder builder = new Info.Builder();
dmBuildInfo.contribute(builder);
Map<String,Object> buildInfo = new HashMap<>();
buildInfo.put("environment", "env");
buildInfo.put("project", "project");
buildInfo.put("name", "name");
buildInfo.put("version", "1.0-42");
buildInfo.put("date", "today");
buildInfo.put("commit", "aaaaaaa");
buildInfo.put("extra", Collections.EMPTY_MAP);
Map<String,Object> map = new HashMap<>();
map.put("buildInfo",buildInfo);
Info info = builder.build();
assertThat(info.getDetails(), CoreMatchers.equalTo(map));
}
示例4: contribute
import org.springframework.boot.actuate.info.Info; //导入依赖的package包/类
@Override
public void contribute(Info.Builder builder) {
Map<String, String> asgNames = new HashMap<String, String>();
asgNames.put("author-dispatcher", envValues.getAutoScaleGroupNameForAuthorDispatcher());
asgNames.put("publish", envValues.getAutoScaleGroupNameForPublish());
asgNames.put("publish-dispatcher", envValues.getAutoScaleGroupNameForPublishDispatcher());
builder.withDetail("auto-scaling-group-names", asgNames);
Map<String, String> authorInfo = new HashMap<String, String>();
authorInfo.put("elastic-load-balancer-name", envValues.getElasticLoadBalancerNameForAuthor());
authorInfo.put("elastic-load-balancer-dns", envValues.getElasticLoadBalancerAuthorDns());
builder.withDetail("author", authorInfo);
builder.withDetail("alarm-notification-topic-arn", envValues.getTopicArn());
}
示例5: contribute
import org.springframework.boot.actuate.info.Info; //导入依赖的package包/类
@Override
public void contribute(Info.Builder builder) {
InetAddress ip = null;
Map<String, String> hostMap = new HashMap<>();
try {
ip = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
e.printStackTrace();
}
hostMap.put("ipAddress", ip.getHostAddress());
hostMap.put("hostname", ip.getHostName());
builder.withDetail("appHostInfo", hostMap);
hostMap = new HashMap<>();
CommandResult commandResult = this.mongoTemplate.executeCommand("{ serverStatus: 1 }");
hostMap.put("hostname", commandResult.getString("host"));
builder.withDetail("mongoDbHostInfo", hostMap);
}
示例6: contribute
import org.springframework.boot.actuate.info.Info; //导入依赖的package包/类
@Override
public void contribute(Info.Builder builder) {
Map<String, Object> details = new LinkedHashMap<>();
metadataProvider.get().getConfiguration().getEnv().getBoms().forEach((k, v) -> {
if (v.getMappings() != null && !v.getMappings().isEmpty()) {
Map<String, Object> bom = new LinkedHashMap<>();
v.getMappings().forEach(it -> {
String requirement = "Spring Boot " + it.determineVersionRangeRequirement();
bom.put(it.getVersion(), requirement);
});
details.put(k, bom);
}
});
if (!details.isEmpty()) {
builder.withDetail("bom-ranges", details);
}
}
示例7: dependencyNoMappingSimpleRange
import org.springframework.boot.actuate.info.Info; //导入依赖的package包/类
@Test
public void dependencyNoMappingSimpleRange() {
Dependency dependency = Dependency.withId("foo", "com.example", "foo",
"1.2.3.RELEASE");
dependency.setVersionRange("[1.1.0.RELEASE, 1.5.0.RELEASE)");
InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults()
.addDependencyGroup("foo", dependency).build();
Info info = getInfo(metadata);
assertThat(info.getDetails()).containsKeys("dependency-ranges");
@SuppressWarnings("unchecked")
Map<String, Object> ranges = (Map<String, Object>) info.getDetails()
.get("dependency-ranges");
assertThat(ranges).containsOnlyKeys("foo");
@SuppressWarnings("unchecked")
Map<String, Object> foo = (Map<String, Object>) ranges.get("foo");
assertThat(foo).containsExactly(
entry("1.2.3.RELEASE", "Spring Boot >=1.1.0.RELEASE and <1.5.0.RELEASE"));
}
示例8: dependencyWithMappingAndOpenRange
import org.springframework.boot.actuate.info.Info; //导入依赖的package包/类
@Test
public void dependencyWithMappingAndOpenRange() {
Dependency dependency = Dependency.withId("foo", null, null, "0.3.0.RELEASE");
dependency.getMappings().add(Dependency.Mapping
.create("[1.1.0.RELEASE, 1.2.0.RELEASE)", null, null, "0.1.0.RELEASE"));
dependency.getMappings().add(Dependency.Mapping
.create("1.2.0.RELEASE", null, null, "0.2.0.RELEASE"));
InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults()
.addDependencyGroup("test", dependency).build();
Info info = getInfo(metadata);
assertDependencyId(info, "foo");
Map<String, Object> foo = getDependencyRangeInfo(info, "foo");
assertThat(foo).containsExactly(
entry("0.1.0.RELEASE", "Spring Boot >=1.1.0.RELEASE and <1.2.0.RELEASE"),
entry("0.2.0.RELEASE", "Spring Boot >=1.2.0.RELEASE"));
}
示例9: dependencyWithMappingAndNoOpenRange
import org.springframework.boot.actuate.info.Info; //导入依赖的package包/类
@Test
public void dependencyWithMappingAndNoOpenRange() {
Dependency dependency = Dependency.withId("foo", null, null, "0.3.0.RELEASE");
dependency.getMappings().add(Dependency.Mapping
.create("[1.1.0.RELEASE, 1.2.0.RELEASE)", null, null, "0.1.0.RELEASE"));
dependency.getMappings().add(Dependency.Mapping
.create("[1.2.0.RELEASE, 1.3.0.RELEASE)", null, null, "0.2.0.RELEASE"));
InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults()
.addDependencyGroup("test", dependency).build();
Info info = getInfo(metadata);
assertDependencyId(info, "foo");
Map<String, Object> foo = getDependencyRangeInfo(info, "foo");
assertThat(foo).containsExactly(
entry("0.1.0.RELEASE", "Spring Boot >=1.1.0.RELEASE and <1.2.0.RELEASE"),
entry("0.2.0.RELEASE", "Spring Boot >=1.2.0.RELEASE and <1.3.0.RELEASE"),
entry("managed", "Spring Boot >=1.3.0.RELEASE"));
}
示例10: withMappings
import org.springframework.boot.actuate.info.Info; //导入依赖的package包/类
@Test
public void withMappings() {
BillOfMaterials bom = BillOfMaterials.create("com.example", "bom", "1.0.0");
bom.getMappings().add(
BillOfMaterials.Mapping.create("[1.3.0.RELEASE,1.3.8.RELEASE]", "1.1.0"));
bom.getMappings().add(
BillOfMaterials.Mapping.create("1.3.8.BUILD-SNAPSHOT", "1.1.1-SNAPSHOT"));
InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults()
.addBom("foo", bom).build();
Info info = getInfo(metadata);
assertThat(info.getDetails()).containsKeys("bom-ranges");
@SuppressWarnings("unchecked")
Map<String, Object> ranges = (Map<String, Object>) info.getDetails()
.get("bom-ranges");
assertThat(ranges).containsOnlyKeys("foo");
@SuppressWarnings("unchecked")
Map<String, Object> foo = (Map<String, Object>) ranges.get("foo");
assertThat(foo).containsExactly(
entry("1.1.0", "Spring Boot >=1.3.0.RELEASE and <=1.3.8.RELEASE"),
entry("1.1.1-SNAPSHOT", "Spring Boot >=1.3.8.BUILD-SNAPSHOT"));
}
示例11: contribute
import org.springframework.boot.actuate.info.Info; //导入依赖的package包/类
@Override
public void contribute(Info.Builder builder) {
Map<String,Object> map = new LinkedHashMap<>();
map.put("environment",environment);
map.put("project", project);
map.put("name", name);
map.put("version", version + (EMPTY.equals(build) ? "" : "-" + build));
map.put("commit", commit);
map.put("date", date);
map.put("extra",new HashMap<>());
builder.withDetail("buildInfo",map);
}
示例12: testContribute
import org.springframework.boot.actuate.info.Info; //导入依赖的package包/类
@Test
public void testContribute() {
// Setup for "auto-scaling-group-names".
String autoScaleGroupNameForAuthorDispatcher = "autoScaleGroupNameForAuthorDispatcher";
String autoScaleGroupNameForPublish = "autoScaleGroupNameForPublish";
String autoScaleGroupNameForPublishDispatcher = "autoScaleGroupNameForPublishDispatcher";
when(envValues.getAutoScaleGroupNameForAuthorDispatcher()).thenReturn(autoScaleGroupNameForAuthorDispatcher);
when(envValues.getAutoScaleGroupNameForPublish()).thenReturn(autoScaleGroupNameForPublish);
when(envValues.getAutoScaleGroupNameForPublishDispatcher()).thenReturn(autoScaleGroupNameForPublishDispatcher);
// Setup for "author".
String elasticLoadBalancerNameForAuthor = "elasticLoadBalancerNameForAuthor";
String elasticLoadBalancerAuthorDns = "elasticLoadBalancerAuthorDns";
when(envValues.getElasticLoadBalancerNameForAuthor()).thenReturn(elasticLoadBalancerNameForAuthor);
when(envValues.getElasticLoadBalancerAuthorDns()).thenReturn(elasticLoadBalancerAuthorDns);
// Setup for "alarm-notification-topic-arn"
String topicArn = "topicArn";
when(envValues.getTopicArn()).thenReturn(topicArn);
Info.Builder builder = new Info.Builder();
infoActuator.contribute(builder);
// Validate "auto-scaling-group-names".
Map<String, Object> info = builder.build().getDetails();
Map<String, String> asgNames = (Map<String, String>) info.get("auto-scaling-group-names");
assertThat(asgNames.get("author-dispatcher"), equalTo(autoScaleGroupNameForAuthorDispatcher));
assertThat(asgNames.get("publish"), equalTo(autoScaleGroupNameForPublish));
assertThat(asgNames.get("publish-dispatcher"), equalTo(autoScaleGroupNameForPublishDispatcher));
// Validate "author"
Map<String, String> authorInfo = (Map<String, String>) info.get("author");
assertThat(authorInfo.get("elastic-load-balancer-name"), equalTo(elasticLoadBalancerNameForAuthor));
assertThat(authorInfo.get("elastic-load-balancer-dns"), equalTo(elasticLoadBalancerAuthorDns));
// Validate "alarm-notification-topic-arn"
assertThat(info.get("alarm-notification-topic-arn"), equalTo(topicArn));
}
示例13: contributeUsedSkillCount
import org.springframework.boot.actuate.info.Info; //导入依赖的package包/类
private void contributeUsedSkillCount(List<User> users, Info.Builder builder) {
int usedSkillCount = (int) users.stream()
.flatMap(p -> p.getSkillsExcludeHidden().stream())
.map(UserSkill::getName)
.distinct()
.count();
builder.withDetail("skills_used", usedSkillCount);
}
示例14: contributeUserSkills
import org.springframework.boot.actuate.info.Info; //导入依赖的package包/类
private void contributeUserSkills(List<User> users, Info.Builder builder) {
IntSummaryStatistics stats = users.stream().mapToInt(u -> u.getSkillsExcludeHidden().size()).summaryStatistics();
Map<String, Double> details = new HashMap<>();
details.put("total", (double) stats.getSum());
details.put("min", (double) stats.getMin());
details.put("max", (double) stats.getMax());
details.put("average", stats.getAverage());
builder.withDetail("personal_skills", details);
}
示例15: contribute
import org.springframework.boot.actuate.info.Info; //导入依赖的package包/类
@Override
public void contribute(Info.Builder builder) {
List<User> users = UserRepository.findAll();
contributeUserCount(builder);
contributeSkillCount(builder);
contributeUsedSkillCount(users, builder);
contributeHiddenSkillCount(builder);
contributeUserSkills(users, builder);
}