Search in sources :

Example 6 with GitProperties

use of org.springframework.boot.info.GitProperties in project spring-boot by spring-projects.

the class GitInfoContributorTests method coerceDate.

@SuppressWarnings("unchecked")
@Test
public void coerceDate() {
    Properties properties = new Properties();
    properties.put("branch", "master");
    properties.put("commit.time", "2016-03-04T14:36:33+0100");
    GitInfoContributor contributor = new GitInfoContributor(new GitProperties(properties));
    Map<String, Object> content = contributor.generateContent();
    assertThat(content.get("commit")).isInstanceOf(Map.class);
    Map<String, Object> commit = (Map<String, Object>) content.get("commit");
    Object commitTime = commit.get("time");
    assertThat(commitTime).isInstanceOf(Date.class);
    assertThat(((Date) commitTime).getTime()).isEqualTo(1457098593000L);
}
Also used : GitProperties(org.springframework.boot.info.GitProperties) GitProperties(org.springframework.boot.info.GitProperties) Properties(java.util.Properties) Map(java.util.Map) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 GitProperties (org.springframework.boot.info.GitProperties)6 Map (java.util.Map)2 Properties (java.util.Properties)2 Date (java.util.Date)1