@Test
public void testArtifacts() throws IOException {

  SliderFileSystem sfs = ServiceTestUtils.initMockFs();
  Service app = new Service();
  app.setName("service1");
  app.setVersion("v1");
  Resource res = new Resource();
  app.setResource(res);
  res.setMemory("512M");
  // no artifact id fails with default type
  Artifact artifact = new Artifact();
  app.setArtifact(artifact);
  String compName = "comp1";
  Component comp = ServiceTestUtils.createComponent(compName);
  app.setComponents(Collections.singletonList(comp));
  try {
    ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
    Assert.fail(EXCEPTION_PREFIX + "service with no artifact id");
  } catch (IllegalArgumentException e) {
    assertEquals(String.format(ERROR_ARTIFACT_ID_FOR_COMP_INVALID, compName),
        e.getMessage());
  }
  // no artifact id fails with SERVICE type
  artifact.setType(Artifact.TypeEnum.SERVICE);
  try {
    ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
    Assert.fail(EXCEPTION_PREFIX + "service with no artifact id");
  } catch (IllegalArgumentException e) {
    assertEquals(ERROR_ARTIFACT_ID_INVALID, e.getMessage());
  }
  // no artifact id fails with TARBALL type
  artifact.setType(Artifact.TypeEnum.TARBALL);
  try {
    ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
    Assert.fail(EXCEPTION_PREFIX + "service with no artifact id");
  } catch (IllegalArgumentException e) {
    assertEquals(String.format(ERROR_ARTIFACT_ID_FOR_COMP_INVALID, compName),
        e.getMessage());
  }
  // everything valid here
  artifact.setType(Artifact.TypeEnum.DOCKER);
  artifact.setId("docker.io/centos:centos7");
  try {
    ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
  } catch (IllegalArgumentException e) {
    LOG.error("service attributes specified should be valid here", e);
    Assert.fail(NO_EXCEPTION_PREFIX + e.getMessage());
  }
  assertThat(app.getLifetime()).isEqualTo(DEFAULT_UNLIMITED_LIFETIME);
}