Skip to content

Commit

Permalink
Refactor(ArtifactContent): Move static maps
Browse files Browse the repository at this point in the history
  • Loading branch information
rkubis committed Jan 30, 2025
1 parent 6902990 commit 658df51
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.apicurio.registry.systemtests.client;

import java.util.HashMap;

public final class ArtifactContent {
public static final String DEFAULT_AVRO = "{\"name\":\"price\",\"namespace\":\"com.example\",\"type\":\"record\"," +
"\"fields\":[{\"name\":\"symbol\",\"type\":\"string\"},{\"name\":\"price\",\"type\":\"string\"}]}";
Expand Down Expand Up @@ -299,4 +301,28 @@ public final class ArtifactContent {
" <price>10.50</price>\n" +
" </item>\n" +
"</shiporder>";
public static final HashMap<ArtifactType, String> ARTIFACTS_BY_TYPE = new HashMap<>(){{
put(ArtifactType.AVRO, DEFAULT_AVRO);
put(ArtifactType.PROTOBUF, DEFAULT_PROTOBUF);
put(ArtifactType.JSON, DEFAULT_JSON);
put(ArtifactType.OPENAPI, DEFAULT_OPENAPI);
put(ArtifactType.ASYNCAPI, DEFAULT_ASYNCAPI);
put(ArtifactType.GRAPHQL, DEFAULT_GRAPHQL);
put(ArtifactType.KCONNECT, DEFAULT_KCONNECT);
put(ArtifactType.WSDL, DEFAULT_WSDL);
put(ArtifactType.XSD, DEFAULT_XSD);
put(ArtifactType.XML, DEFAULT_XML);
}};
public static final HashMap<ArtifactType, String> UPDATED_ARTIFACTS_BY_TYPE = new HashMap<>(){{
put(ArtifactType.AVRO, DEFAULT_AVRO_UPDATED);
put(ArtifactType.PROTOBUF, DEFAULT_PROTOBUF_UPDATED);
put(ArtifactType.JSON, DEFAULT_JSON_UPDATED);
put(ArtifactType.OPENAPI, DEFAULT_OPENAPI_UPDATED);
put(ArtifactType.ASYNCAPI, DEFAULT_ASYNCAPI_UPDATED);
put(ArtifactType.GRAPHQL, DEFAULT_GRAPHQL_UPDATED);
put(ArtifactType.KCONNECT, DEFAULT_KCONNECT_UPDATED);
put(ArtifactType.WSDL, DEFAULT_WSDL_UPDATED);
put(ArtifactType.XSD, DEFAULT_XSD_UPDATED);
put(ArtifactType.XML, DEFAULT_XML_UPDATED);
}};
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,11 @@
import org.junit.jupiter.api.Assertions;
import org.slf4j.Logger;

import java.util.HashMap;
import java.util.UUID;

public class CreateReadUpdateDelete {
protected static Logger LOGGER = LoggerUtils.getLogger();

private static final HashMap<ArtifactType, String> artifacts = new HashMap<>(){{
put(ArtifactType.AVRO, ArtifactContent.DEFAULT_AVRO);
put(ArtifactType.PROTOBUF, ArtifactContent.DEFAULT_PROTOBUF);
put(ArtifactType.JSON, ArtifactContent.DEFAULT_JSON);
put(ArtifactType.OPENAPI, ArtifactContent.DEFAULT_OPENAPI);
put(ArtifactType.ASYNCAPI, ArtifactContent.DEFAULT_ASYNCAPI);
put(ArtifactType.GRAPHQL, ArtifactContent.DEFAULT_GRAPHQL);
put(ArtifactType.KCONNECT, ArtifactContent.DEFAULT_KCONNECT);
put(ArtifactType.WSDL, ArtifactContent.DEFAULT_WSDL);
put(ArtifactType.XSD, ArtifactContent.DEFAULT_XSD);
put(ArtifactType.XML, ArtifactContent.DEFAULT_XML);
}};
private static final HashMap<ArtifactType, String> updatedArtifacts = new HashMap<>(){{
put(ArtifactType.AVRO, ArtifactContent.DEFAULT_AVRO_UPDATED);
put(ArtifactType.PROTOBUF, ArtifactContent.DEFAULT_PROTOBUF_UPDATED);
put(ArtifactType.JSON, ArtifactContent.DEFAULT_JSON_UPDATED);
put(ArtifactType.OPENAPI, ArtifactContent.DEFAULT_OPENAPI_UPDATED);
put(ArtifactType.ASYNCAPI, ArtifactContent.DEFAULT_ASYNCAPI_UPDATED);
put(ArtifactType.GRAPHQL, ArtifactContent.DEFAULT_GRAPHQL_UPDATED);
put(ArtifactType.KCONNECT, ArtifactContent.DEFAULT_KCONNECT_UPDATED);
put(ArtifactType.WSDL, ArtifactContent.DEFAULT_WSDL_UPDATED);
put(ArtifactType.XSD, ArtifactContent.DEFAULT_XSD_UPDATED);
put(ArtifactType.XML, ArtifactContent.DEFAULT_XML_UPDATED);
}};

public static void testCreateReadUpdateDeleteAvro(ApicurioRegistry apicurioRegistry) {
testCreateReadUpdateDelete(apicurioRegistry, null, null, ArtifactType.AVRO, false);
}
Expand Down Expand Up @@ -98,8 +72,8 @@ public static void testCreateReadUpdateDelete(
// Prepare necessary variables
String artifactGroupId = "registry-" + UUID.randomUUID();
String artifactId = "registry-" + UUID.randomUUID();
String artifactContent = artifacts.get(artifactType);
String updatedArtifactContent = updatedArtifacts.get(artifactType);
String artifactContent = ArtifactContent.ARTIFACTS_BY_TYPE.get(artifactType);
String updatedArtifactContent = ArtifactContent.UPDATED_ARTIFACTS_BY_TYPE.get(artifactType);
String hostname = ApicurioRegistryUtils.getApicurioRegistryHostname(apicurioRegistry);

// Get API client
Expand Down

0 comments on commit 658df51

Please sign in to comment.