-
Notifications
You must be signed in to change notification settings - Fork 658
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(artifact_service): moved ArtifactServiceSpec (groovy) unit t…
…ests to ArtifactServiceTest (java)
- Loading branch information
1 parent
7772f58
commit 9ba2ef4
Showing
2 changed files
with
100 additions
and
105 deletions.
There are no files selected for viewing
105 changes: 0 additions & 105 deletions
105
igor-web/src/test/groovy/com/netflix/spinnaker/igor/artifacts/ArtifactServiceSpec.groovy
This file was deleted.
Oops, something went wrong.
100 changes: 100 additions & 0 deletions
100
igor-web/src/test/java/com/netflix/spinnaker/igor/artifacts/ArtifactServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* | ||
* 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 static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import com.netflix.spinnaker.kork.artifacts.model.Artifact; | ||
import com.netflix.spinnaker.kork.web.exceptions.NotFoundException; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class ArtifactServiceTest { | ||
|
||
private ArtifactServices artifactServices; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
artifactServices = new ArtifactServices(); | ||
Map<String, ArtifactService> services = new HashMap<>(); | ||
services.put("artifactory", new TestArtifactService()); | ||
artifactServices.addServices(services); | ||
} | ||
|
||
@Test | ||
public void findsMatchingService() { | ||
ArtifactService service = artifactServices.getService("artifactory"); | ||
assertThat(service).isNotNull(); | ||
} | ||
|
||
@Test | ||
public void doesNotFindNonMatchingService() { | ||
ArtifactService service = artifactServices.getService("what"); | ||
assertThat(service).isNull(); | ||
} | ||
|
||
@Test | ||
public void serviceFindsArtifactVersions() { | ||
ArtifactService service = artifactServices.getService("artifactory"); | ||
List<String> versions = service.getArtifactVersions("deb", "test", (List<String>) null); | ||
|
||
assertThat(versions).isNotNull(); | ||
assertThat(versions).isNotEmpty(); | ||
assertThat(versions.size()).isGreaterThan(0); | ||
} | ||
|
||
@Test | ||
public void serviceFindsOnlySnapshotArtifacts() { | ||
ArtifactService service = artifactServices.getService("artifactory"); | ||
List<String> versions = service.getArtifactVersions("deb", "test", "snapshot"); | ||
|
||
assertThat(versions).isNotNull(); | ||
assertThat(versions).isNotEmpty(); | ||
assertThat(versions.size()).isEqualTo(1); | ||
} | ||
|
||
@Test | ||
public void serviceFindsArtifact() { | ||
ArtifactService service = artifactServices.getService("artifactory"); | ||
Artifact artifact = service.getArtifact("deb", "test", "v0.4.0"); | ||
|
||
assertThat(artifact).isNotNull(); | ||
assertThat(artifact.getName()).isEqualTo("test"); | ||
assertThat(artifact.getVersion()).isEqualTo("v0.4.0"); | ||
} | ||
|
||
@Test | ||
public void versionsListIsEmptyWhenNoVersionsFound() { | ||
ArtifactService service = artifactServices.getService("artifactory"); | ||
List<String> versions = service.getArtifactVersions("deb", "blah", ""); | ||
|
||
assertThat(versions).isNotNull(); | ||
assertThat(versions).isEmpty(); | ||
} | ||
|
||
@Test | ||
public void notFoundExceptionIsThrownWhenArtifactNotFound() { | ||
ArtifactService service = artifactServices.getService("artifactory"); | ||
assertThrows(NotFoundException.class, () -> service.getArtifact("deb", "blah", "v0.0.1")); | ||
} | ||
} |