Skip to content

Commit

Permalink
add tags to JobArtifact (#625)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andyz26 authored Feb 1, 2024
1 parent b5f1e79 commit 0706d1c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,10 @@ public class JobArtifact {
// Job entrypoint clas.
@JsonProperty("entrypoint")
String entrypoint;

/**
* tags for the current job artifact. E.g. jdk version, SBN version etc.
*/
@JsonProperty("tags")
Map<String, String> tags;
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,38 @@ public void testIfJobArtifactIsSerializableByJson() throws Exception {
.createdAt(Instant.ofEpochMilli(1668135952L))
.runtimeType("sbn")
.dependencies(ImmutableMap.of("de1", "1.0.0"))
.tags(ImmutableMap.of("jdkVersion", "9"))
.entrypoint("entrypoint")
.build();
String metaJson = Jackson.toJSON(mapper, null, artifact);
assertEquals(metaJson, "{\"artifactID\":{\"resourceID\":\"id\"},\"name\":\"proj1\",\"version\":\"v1\",\"createdAt\":1668135.952000000,\"runtimeType\":\"sbn\",\"dependencies\":{\"de1\":\"1.0.0\"},\"entrypoint\":\"entrypoint\"}");
assertEquals(metaJson, "{\"artifactID\":{\"resourceID\":\"id\"},\"name\":\"proj1\",\"version\":\"v1\",\"createdAt\":1668135.952000000,\"runtimeType\":\"sbn\",\"dependencies\":{\"de1\":\"1.0.0\"},\"entrypoint\":\"entrypoint\",\"tags\":{\"jdkVersion\":\"9\"}}");

final JobArtifact actual = Jackson.fromJSON(mapper, metaJson, JobArtifact.class);
assertEquals(artifact, actual);
}

@Test
public void testIfJobArtifactIsSerializableByJsonBackCompat() throws Exception {
final JobArtifact artifact =
JobArtifact.builder()
.artifactID(ArtifactID.of("id"))
.name("proj1")
.version("v1")
.createdAt(Instant.ofEpochMilli(1668135952L))
.runtimeType("sbn")
.dependencies(ImmutableMap.of("de1", "1.0.0"))
.entrypoint("entrypoint")
.build();
String metaJson = Jackson.toJSON(mapper, null, artifact);
String rawStr = "{\"artifactID\":{\"resourceID\":\"id\"},\"name\":\"proj1\",\"version\":\"v1\",\"createdAt\":1668135.952000000,\"runtimeType\":\"sbn\",\"dependencies\":{\"de1\":\"1.0.0\"},\"entrypoint\":\"entrypoint\",\"tags\":null}";

assertEquals(metaJson, rawStr);

JobArtifact actual = Jackson.fromJSON(mapper, rawStr, JobArtifact.class);
assertEquals(artifact, actual);

String rawStrOldVersion = "{\"artifactID\":{\"resourceID\":\"id\"},\"name\":\"proj1\",\"version\":\"v1\",\"createdAt\":1668135.952000000,\"runtimeType\":\"sbn\",\"dependencies\":{\"de1\":\"1.0.0\"},\"entrypoint\":\"entrypoint\"}";
actual = Jackson.fromJSON(mapper, rawStrOldVersion, JobArtifact.class);
assertEquals(artifact, actual);
}
}

0 comments on commit 0706d1c

Please sign in to comment.