Java 类org.springframework.boot.actuate.info.Info 实例源码

项目:document-management-store-app    文件:DmBuildInfoTest.java   
@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));
}
项目:document-management-store-app    文件:DmBuildInfoTest.java   
@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));
}
项目:document-management-store-app    文件:DmBuildInfoTest.java   
@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));
}
项目:aem-orchestrator    文件:InfoActuator.java   
@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());
}
项目:voter-service    文件:HostInfoContributor.java   
@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);
}
项目:initializr    文件:BomRangesInfoContributor.java   
@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);
    }
}
项目:initializr    文件:DependencyRangesInfoContributorTests.java   
@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"));
}
项目:initializr    文件:DependencyRangesInfoContributorTests.java   
@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"));
}
项目:initializr    文件:DependencyRangesInfoContributorTests.java   
@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"));
}
项目:initializr    文件:BomRangesInfoContributorTests.java   
@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"));
}
项目:document-management-store-app    文件:DmBuildInfo.java   
@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);
}
项目:aem-orchestrator    文件:InfoActuatorTest.java   
@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));
}
项目:SkillWill    文件:StatisticsInfoContributor.java   
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);
}
项目:SkillWill    文件:StatisticsInfoContributor.java   
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);
}
项目:SkillWill    文件:StatisticsInfoContributor.java   
@Override
public void contribute(Info.Builder builder) {
  List<User> users = UserRepository.findAll();

  contributeUserCount(builder);
  contributeSkillCount(builder);
  contributeUsedSkillCount(users, builder);
  contributeHiddenSkillCount(builder);
  contributeUserSkills(users, builder);
}
项目:orbit-spring    文件:ActorInfoDetailsContainer.java   
synchronized void mergeDetailsFrom(ActorInfoContributorReference actorInfoContributorReference)
{
    Info.Builder builder = new Info.Builder();
    actorInfoContributorReference.getInfoContributor().contribute(builder);
    Map<String, Object> whereToPutDetails = details;
    for (Function<ActorInfoContributorReference, String> handler: detailLevelHandlers)
    {
        String key = handler.apply(actorInfoContributorReference);
        whereToPutDetails.putIfAbsent(key, new HashMap<String, Object>());
        //noinspection unchecked
        whereToPutDetails = (Map<String, Object>) whereToPutDetails.get(key);
    }
    whereToPutDetails.putAll(builder.build().getDetails());
}
项目:orbit-spring    文件:ActorInfoContributorLifetimeExtension.java   
@Override
public void contribute(final Info.Builder builder)
{
    populateActorInfoContainerWhileRemovingExpiredReferences();
    Map<String, Object> details = actorInfoDetailsContainer.getDetailsSnapshot();
    if (!details.isEmpty())
    {
        builder.withDetail("actors", details);
    }
}
项目:orbit-spring    文件:ActorInfoContributorIntegrationTest.java   
@Override
public void contribute(final Info.Builder builder)
{
    builder.withDetail("constructorInjectedValue", constructorInjectedValue)
            .withDetail("fieldInjectedValue", fieldInjectedValue);
    super.contribute(builder);
}
项目:service-authorization    文件:AuthProvidersInfoContributor.java   
@Override
public void contribute(Info.Builder builder) {
    final Map<String, OAuth2LoginDetails> oauth2Details =
            settingsRepository.findOne("default").getoAuth2LoginDetails();

    final Map<String, AuthProviderInfo> providers = providersMap.values()
            .stream()
            .filter(p -> !p.isConfigDynamic() || (null != oauth2Details && oauth2Details.containsKey(p.getName())))
            .collect(Collectors
                    .toMap(OAuthProvider::getName,
                            p -> new AuthProviderInfo(p.getButton(), p.buildPath(getAuthBasePath()))));

    builder.withDetail("auth_extensions", providers);
    //@formatter:on
}
项目:service-authorization    文件:MetadataContributor.java   
@Override
public void contribute(Info.Builder builder) {
    builder
            .withDetail("metadata", ImmutableMap
                    .builder()
                    .put("project_roles",
                            stream(ProjectRole.values()).map(Enum::name).collect(Collectors.toList()))
                    .build());
    //@formatter:on
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:InfoEndpoint.java   
@Override
public Map<String, Object> invoke() {
    Info.Builder builder = new Info.Builder();
    for (InfoContributor contributor : this.infoContributors) {
        contributor.contribute(builder);
    }
    builder.withDetails(getAdditionalInfo());
    Info build = builder.build();
    return build.getDetails();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:InfoContributorAutoConfigurationTests.java   
@Bean
public InfoContributor customInfoContributor() {
    return new InfoContributor() {
        @Override
        public void contribute(Info.Builder builder) {
        }
    };
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointAutoConfigurationTests.java   
@Bean
@Order(InfoContributorAutoConfiguration.DEFAULT_ORDER - 1)
public InfoContributor myInfoContributor() {
    return new InfoContributor() {
        @Override
        public void contribute(Info.Builder builder) {
            builder.withDetail("name", "bar");
            builder.withDetail("version", "1.0");
        }
    };
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:InfoEndpointTests.java   
@Bean
public InfoContributor infoContributor() {
    return new InfoContributor() {

        @Override
        public void contribute(Info.Builder builder) {
            builder.withDetail("key1", "value1");
        }

    };
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:InfoEndpointCompatibilityTests.java   
private InfoContributor infoContributor() {
    return new InfoContributor() {

        @Override
        public void contribute(Info.Builder builder) {
            builder.withDetail("key1", "value1");
        }

    };
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:InfoMvcEndpointTests.java   
@Bean
public InfoContributor beanName1() {
    return new InfoContributor() {

        @Override
        public void contribute(Info.Builder builder) {
            Map<String, Object> content = new LinkedHashMap<String, Object>();
            content.put("key11", "value11");
            content.put("key12", "value12");
            builder.withDetail("beanName1", content);
        }
    };
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:InfoMvcEndpointTests.java   
@Bean
public InfoContributor beanName2() {
    return new InfoContributor() {
        @Override
        public void contribute(Info.Builder builder) {
            Map<String, Object> content = new LinkedHashMap<String, Object>();
            content.put("key21", "value21");
            content.put("key22", "value22");
            builder.withDetail("beanName2", content);
        }
    };
}
项目:spring-boot-concourse    文件:InfoEndpoint.java   
@Override
public Map<String, Object> invoke() {
    Info.Builder builder = new Info.Builder();
    for (InfoContributor contributor : this.infoContributors) {
        contributor.contribute(builder);
    }
    builder.withDetails(getAdditionalInfo());
    Info build = builder.build();
    return build.getDetails();
}
项目:spring-boot-concourse    文件:InfoContributorAutoConfigurationTests.java   
@Bean
public InfoContributor customInfoContributor() {
    return new InfoContributor() {
        @Override
        public void contribute(Info.Builder builder) {
        }
    };
}
项目:spring-boot-concourse    文件:EndpointAutoConfigurationTests.java   
@Bean
@Order(InfoContributorAutoConfiguration.DEFAULT_ORDER - 1)
public InfoContributor myInfoContributor() {
    return new InfoContributor() {
        @Override
        public void contribute(Info.Builder builder) {
            builder.withDetail("name", "bar");
            builder.withDetail("version", "1.0");
        }
    };
}
项目:spring-boot-concourse    文件:InfoEndpointTests.java   
@Bean
public InfoContributor infoContributor() {
    return new InfoContributor() {

        @Override
        public void contribute(Info.Builder builder) {
            builder.withDetail("key1", "value1");
        }

    };
}
项目:spring-boot-concourse    文件:InfoEndpointCompatibilityTests.java   
private InfoContributor infoContributor() {
    return new InfoContributor() {

        @Override
        public void contribute(Info.Builder builder) {
            builder.withDetail("key1", "value1");
        }

    };
}
项目:spring-boot-concourse    文件:InfoMvcEndpointTests.java   
@Bean
public InfoContributor beanName1() {
    return new InfoContributor() {

        @Override
        public void contribute(Info.Builder builder) {
            Map<String, Object> content = new LinkedHashMap<String, Object>();
            content.put("key11", "value11");
            content.put("key12", "value12");
            builder.withDetail("beanName1", content);
        }
    };
}
项目:spring-boot-concourse    文件:InfoMvcEndpointTests.java   
@Bean
public InfoContributor beanName2() {
    return new InfoContributor() {
        @Override
        public void contribute(Info.Builder builder) {
            Map<String, Object> content = new LinkedHashMap<String, Object>();
            content.put("key21", "value21");
            content.put("key22", "value22");
            builder.withDetail("beanName2", content);
        }
    };
}
项目:initializr    文件:DependencyRangesInfoContributorTests.java   
@Test
public void noDependencyWithVersion() {
    InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults()
            .build();
    Info info = getInfo(metadata);
    assertThat(info.getDetails()).doesNotContainKeys("dependency-ranges");
}
项目:initializr    文件:DependencyRangesInfoContributorTests.java   
@Test
public void dependencyWithNoMapping() {
    Dependency dependency = Dependency.withId("foo", "com.example", "foo",
            "1.2.3.RELEASE");
    InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults()
            .addDependencyGroup("foo", dependency).build();
    Info info = getInfo(metadata);
    assertThat(info.getDetails()).doesNotContainKeys("dependency-ranges");
}
项目:initializr    文件:DependencyRangesInfoContributorTests.java   
@Test
public void dependencyWithRangeOnArtifact() {
    Dependency dependency = Dependency.withId("foo", "com.example", "foo",
            "1.2.3.RELEASE");
    dependency.getMappings().add(Dependency.Mapping
            .create("[1.1.0.RELEASE, 1.2.0.RELEASE)", null, "foo2", null));
    InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults()
            .addDependencyGroup("foo", dependency).build();
    Info info = getInfo(metadata);
    assertThat(info.getDetails()).doesNotContainKeys("dependency-ranges");
}
项目:initializr    文件:DependencyRangesInfoContributorTests.java   
@Test
public void dependencyWithRangeAndBom() {
    BillOfMaterials bom = BillOfMaterials.create("com.example", "bom", "1.0.0");
    Dependency dependency = Dependency.withId("foo", "com.example", "foo",
            "1.2.3.RELEASE");
    dependency.getMappings().add(Dependency.Mapping
            .create("[1.1.0.RELEASE, 1.2.0.RELEASE)", null, null, "0.1.0.RELEASE"));
    dependency.setBom("bom");
    InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults()
            .addBom("bom", bom)
            .addDependencyGroup("foo", dependency).build();
    Info info = getInfo(metadata);
    assertThat(info.getDetails()).doesNotContainKeys("dependency-ranges");
}
项目:initializr    文件:DependencyRangesInfoContributorTests.java   
@SuppressWarnings("unchecked")
private void assertDependencyId(Info info, String... dependencyIds) {
    assertThat(info.getDetails()).containsKeys("dependency-ranges");
    Map<String, Object> ranges = (Map<String, Object>) info.getDetails()
            .get("dependency-ranges");
    assertThat(ranges).containsOnlyKeys(dependencyIds);
}
项目:initializr    文件:DependencyRangesInfoContributorTests.java   
@SuppressWarnings("unchecked")
private Map<String,Object> getDependencyRangeInfo(Info info, String id) {
    assertThat(info.getDetails()).containsKeys("dependency-ranges");
    Map<String, Object> ranges = (Map<String, Object>) info.getDetails()
            .get("dependency-ranges");
    return (Map<String, Object>) ranges.get(id);
}