SpaceRepository implements Comparable<SpaceRepository> { public static String pastRepositoryId(String repositoryId, int weeks) { return toRepositoryId(toDateTime(repositoryId).minusWeeks(weeks)); }  String id(); SpaceRepository withId(String id); String type(); SpaceRepository withType(String type); Map<String, Object> settings(); SpaceRepository withSettings(Map<String, Object> settings); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); @Override // ordered from latest to oldest repository int compareTo(SpaceRepository other); static String currentRepositoryId(); static String toRepositoryId(DateTime date); static DateTime toDateTime(String repositoryId); static String pastRepositoryId(String repositoryId, int weeks);  }
@Test public void testGetPreviousRepositoryId() { assertEquals("2015-11", SpaceRepository.pastRepositoryId("2015-12", 1)); assertEquals("2015-08", SpaceRepository.pastRepositoryId("2015-12", 4)); assertEquals("2014-52", SpaceRepository.pastRepositoryId("2015-12", 12)); assertEquals("2014-52", SpaceRepository.pastRepositoryId("2015-01", 1)); assertEquals("2014-50", SpaceRepository.pastRepositoryId("2015-01", 3)); assertEquals("2014-01", SpaceRepository.pastRepositoryId("2015-01", 52)); }