/*
 *
 * Copyright 2019 Netflix, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License")
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package com.netflix.spinnaker.igor.artifacts;

import com.netflix.spinnaker.igor.model.ArtifactServiceProvider;
import com.netflix.spinnaker.kork.artifacts.model.Artifact;
import com.netflix.spinnaker.kork.web.exceptions.NotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class TestArtifactService implements ArtifactService {
  @Override
  public ArtifactServiceProvider artifactServiceProvider() {
    return ArtifactServiceProvider.CUSTOM;
  }

  @Override
  public List<String> getArtifactVersions(String name, String releaseStatus) {
    if (!name.equals("test")) {
      return Collections.emptyList();
    }
    List<String> versions = new ArrayList<>();
    if (releaseStatus == null || releaseStatus.isEmpty() || releaseStatus.contains("final")) {
      versions.add("v0.1.0");
      versions.add("v0.2.0");
      versions.add("v0.3.0");
      versions.add("v0.4.0");
    }
    if (releaseStatus == null || releaseStatus.isEmpty() || releaseStatus.contains("snapshot")) {
      versions.add("v0.5.0~SNAPSHOT");
    }
    return versions;
  }

  @Override
  public Artifact getArtifact(String name, String version) {
    if (!name.equals("test") && !version.equals("v0.4.0")) {
      throw new NotFoundException("Artifact not found");
    }
    return new Artifact(
        "deb",
        false,
        "test",
        "v0.4.0",
        "artifactory//test/v0.4.0",
        "artifactory//test/v0.4.0",
        Collections.emptyMap(),
        "testAccount",
        "jenkins//test/v0.4.0",
        "1234");
  }
}

@@ -1914,20 +1914,16 @@
 urn 
-new 
 Artifact
 (%0A  
@@ -1918,17 +1918,26 @@
 Artifact
-(
+.builder()
 %0A       
@@ -1941,14 +1941,20 @@
     
+.type(
 %22deb%22
-,
+)
 %0A   
@@ -1962,14 +1962,26 @@
     
+.customKind(
 false
-,
+)
 %0A   
@@ -1989,15 +1989,21 @@
     
+.name(
 %22test%22
-,
+)
 %0A   
@@ -2007,24 +2007,33 @@
         
+.version(
 %22v0.4.0%22
 ,%0A      
@@ -2020,25 +2020,25 @@
 ion(%22v0.4.0%22
-,
+)
 %0A        %22ar
@@ -2026,32 +2026,42 @@
 0.4.0%22)%0A        
+.location(
 %22artifactory//te
@@ -2062,33 +2062,33 @@
 ry//test/v0.4.0%22
-,
+)
 %0A        %22artifa
@@ -2080,16 +2080,27 @@
         
+.reference(
 %22artifac
@@ -2109,33 +2109,33 @@
 ry//test/v0.4.0%22
-,
+)
 %0A        Collect
@@ -2127,16 +2127,26 @@
         
+.metadata(
 Collecti
@@ -2159,17 +2159,17 @@
 ptyMap()
-,
+)
 %0A       
@@ -2169,16 +2169,33 @@
         
+.artifactAccount(
 %22testAcc
@@ -2199,17 +2199,17 @@
 Account%22
-,
+)
 %0A       
@@ -2209,16 +2209,28 @@
         
+.provenance(
 %22jenkins
@@ -2243,17 +2243,17 @@
 /v0.4.0%22
-,
+)
 %0A       
@@ -2257,14 +2257,37 @@
     
-%221234%22
+.uuid(%221234%22)%0A        .build(
 );%0A 

Use builder to create artifacts (#559)