DeploymentMetaData { static String getServiceFromBuildName(String buildName) { if (null == buildName || buildName.isEmpty()) { return buildName; } return buildName.substring(0, buildName.lastIndexOf('-')); } DeploymentMetaData(String serviceName, String buildStamp); String getServiceName(); void setServiceName(String serviceName); String getBuildStamp(); void setBuildStamp(String buildStamp); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void convertToServiceName_usualCase() { assertEquals("hawkular-apm", DeploymentMetaData.getServiceFromBuildName("hawkular-apm-1")); }
@Test public void convertToServiceName_reallyLargeBuildNumber() { assertEquals("hawkular-apm", DeploymentMetaData.getServiceFromBuildName("hawkular-apm-111111111111111111111111111111111111111111")); }
@Test public void convertToServiceName_withoutNumber() { assertEquals("hawkular", DeploymentMetaData.getServiceFromBuildName("hawkular-apm")); }
@Test public void convertToServiceName_empty() { assertEquals("", DeploymentMetaData.getServiceFromBuildName("")); }
@Test public void convertToServiceName_nil() { assertEquals(null, DeploymentMetaData.getServiceFromBuildName(null)); }