diff --git a/.github/workflows/maven-central-push.yml b/.github/workflows/maven-central-push.yml
index b2665d60..3564e316 100644
--- a/.github/workflows/maven-central-push.yml
+++ b/.github/workflows/maven-central-push.yml
@@ -25,10 +25,10 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.ref }}
- - name: Set up JDK 11
+ - name: Set up JDK 17
uses: actions/setup-java@v2
with:
- java-version: "11"
+ java-version: "17"
distribution: "adopt"
server-id: ossrh
server-username: MAVEN_USERNAME
diff --git a/.github/workflows/maven-pr.yml b/.github/workflows/maven-pr.yml
index 2b2873ea..0b3ba30a 100644
--- a/.github/workflows/maven-pr.yml
+++ b/.github/workflows/maven-pr.yml
@@ -36,10 +36,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- - name: Set up JDK 11
+ - name: Set up JDK 17
uses: actions/setup-java@v2
with:
- java-version: "11"
+ java-version: "17"
distribution: "adopt"
- name: Build with Maven
run: mvn -B package --file pom.xml
diff --git a/pom-maven-central.xml b/pom-maven-central.xml
index 2137a7e0..e0380d1a 100644
--- a/pom-maven-central.xml
+++ b/pom-maven-central.xml
@@ -7,7 +7,7 @@
kloadgen
- 5.6.7
+ 5.6.8
KLoadGen
Load Generation Jmeter plugin for Kafka Cluster. Supporting AVRO, JSON Schema and Protobuf schema types. Generate Artificial
@@ -20,22 +20,11 @@
Mozilla Public License 2.0
https://github.com/sngular/kloadgen/blob/master/LICENSE
repo
-
+
-
- AnxoGomezSngular
- Anxo Gómez Sánchez
- anxo.gomez@sngular.com
- Sngular
- https://sngular.github.io/
-
- Developer
-
- Europe/Madrid
-
jegarcia
Jose Enrique Garcia Maciñeiras
@@ -195,13 +184,24 @@
davidgarciago
David García Gondell
david.garciag@sngular.com
- Corunet
- https://corunet.github.io/
+ Sngular
+ https://sngular.github.io/
Junior Developer
Europe/Madrid
+
+ AnxoGomezSngular
+ Anxo Gómez Sánchez
+ anxo.gomez@sngular.com
+ Sngular
+ https://sngular.github.io/
+
+ Developer
+
+ Europe/Madrid
+
pedrogarcia
Pedro Garcia
@@ -235,6 +235,17 @@
Europe/Madrid
+
+ rabad-sng
+ Raúl Abad
+ raul.abad@sngular.com
+ Sngular
+ https://www.sngular.com
+
+ Senior Backend Developer
+
+ Europe/Madrid
+
dhergon
David Hernández González
@@ -310,24 +321,24 @@
- 3.22.0
+ 3.24.2
1.2.0
1.5.1
- 1.11.0
+ 1.11.2
1.9.4
4.4
3.12.0
2.8.6
- 31.0.1-jre
+ 32.0.0-jre
2.4.0-b180830.0359
- 11
+ 17
provided
- 5.5
+ 5.6.2
2.6.0
5.8.2
7.1.1
- 2.4.1.Final
- 3.1.0
+ 2.4.3.Final
+ 3.5.1
1.18.22
0.9.5
4.2.0
@@ -335,21 +346,10 @@
4.5.0
2.0.0-alpha1
1.3.1
- 2.32.0
+ 2.35.1
-
- org.apache.jmeter
- jorphan
- ${jmeter.version}
-
-
- org.slf4j
- slf4j-api
-
-
-
org.apache.kafka
kafka-clients
@@ -365,11 +365,6 @@
-
- com.google.guava
- guava
- ${guava.version}
-
com.eclipsesource.minimal-json
minimal-json
@@ -389,7 +384,12 @@
com.fasterxml.jackson.core
jackson-core
- 2.13.1
+ 2.15.2
+
+
+ com.fasterxml.jackson.core
+ jackson-annotations
+ 2.15.2
org.projectlombok
@@ -437,6 +437,12 @@
io.apicurio
apicurio-registry-client
${apicurio-registry.version}
+
+
+ org.jboss.slf4j
+ slf4j-jboss-logmanager
+
+
io.apicurio
@@ -461,7 +467,7 @@
org.apache.avro
avro-protobuf
- 1.11.0
+ 1.11.2
com.github.os72
@@ -474,10 +480,16 @@
4.0.1
runtime
+
+ com.google.api.grpc
+ proto-google-common-protos
+ 2.24.0
+
org.slf4j
slf4j-api
${slf4j-api.version}
+ provided
org.apache.commons
@@ -502,7 +514,7 @@
com.github.everit-org.json-schema
org.everit.json.schema
- 1.14.0
+ 1.14.2
@@ -636,7 +648,42 @@
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+ 3.1.2
+
+
+ com.puppycrawl.tools
+ checkstyle
+ 10.2
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+
+ checkstyle.xml
+ true
+ true
+ false
+
+
+
+ validate
+ validate
+
+ check
+
+
+
+
com.github.ekryd.sortpom
sortpom-maven-plugin
@@ -653,7 +700,7 @@
org.apache.maven.plugins
maven-compiler-plugin
- 3.6.0
+ 3.8.1
true
true
@@ -698,7 +745,7 @@
cobertura-maven-plugin
2.7
-
+
xml
@@ -718,7 +765,7 @@
org.apache.maven.plugins
maven-surefire-plugin
- 2.22.2
+ 3.1.2
org.sonatype.plugins
@@ -769,10 +816,6 @@
${jmeter.version}
provided
-
- org.apache.jmeter
- jorphan
-
org.apache.logging.log4j
log4j-slf4j-impl
@@ -804,13 +847,16 @@
org.apache.maven.plugins
maven-shade-plugin
- 2.4.2
+ 3.2.4
org/apache/jmeter/jmeter.properties
+
+ *.proto
+
${project.artifactId}-${project.version}
@@ -839,10 +885,6 @@
ApacheJMeter_java
${jmeter.version}
-
- org.apache.jmeter
- jorphan
-
org.apache.logging.log4j
log4j-slf4j-impl
@@ -945,4 +987,16 @@
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+
+ checkstyle.xml
+
+
+
+
+
diff --git a/pom.xml b/pom.xml
index b9fad739..deb1aaac 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,11 +7,11 @@
kloadgen
- 5.6.7
+ 5.6.8
KLoadGen
Load Generation Jmeter plugin for Kafka Cluster. Supporting AVRO, JSON Schema and Protobuf schema types. Generate Artificial
- data base on Data specification
+ data based on Data specification
https://sngular.github.io/kloadgen/
@@ -191,6 +191,17 @@
Europe/Madrid
+
+ AnxoGomezSngular
+ Anxo Gómez Sánchez
+ anxo.gomez@sngular.com
+ Sngular
+ https://sngular.github.io/
+
+ Developer
+
+ Europe/Madrid
+
pedrogarcia
Pedro Garcia
@@ -213,6 +224,17 @@
Europe/Madrid
+
+ nuriaricorf
+ Nuria Rico Freire
+ nuria.rico@sngular.com
+ Sngular
+ https://sngular.github.io/
+
+ Junior Developer
+
+ Europe/Madrid
+
rabad-sng
Raúl Abad
@@ -299,24 +321,24 @@
- 3.22.0
+ 3.24.2
1.2.0
1.5.1
- 1.11.0
+ 1.11.2
1.9.4
4.4
3.12.0
2.8.6
32.0.0-jre
2.4.0-b180830.0359
- 11
+ 17
provided
- 5.5
+ 5.6.2
2.6.0
5.8.2
7.1.1
- 2.4.1.Final
- 3.1.0
+ 2.4.3.Final
+ 3.5.1
1.18.22
0.9.5
4.2.0
@@ -328,17 +350,6 @@
-
- org.apache.jmeter
- jorphan
- ${jmeter.version}
-
-
- org.slf4j
- slf4j-api
-
-
-
org.apache.kafka
kafka-clients
@@ -354,11 +365,6 @@
-
- com.google.guava
- guava
- ${guava.version}
-
com.eclipsesource.minimal-json
minimal-json
@@ -378,7 +384,12 @@
com.fasterxml.jackson.core
jackson-core
- 2.13.1
+ 2.15.2
+
+
+ com.fasterxml.jackson.core
+ jackson-annotations
+ 2.15.2
org.projectlombok
@@ -456,7 +467,7 @@
org.apache.avro
avro-protobuf
- 1.11.0
+ 1.11.2
com.github.os72
@@ -469,6 +480,11 @@
4.0.1
runtime
+
+ com.google.api.grpc
+ proto-google-common-protos
+ 2.24.0
+
org.slf4j
slf4j-api
@@ -498,7 +514,7 @@
com.github.everit-org.json-schema
org.everit.json.schema
- 1.14.0
+ 1.14.2
@@ -685,7 +701,7 @@
org.apache.maven.plugins
maven-compiler-plugin
- 3.6.0
+ 3.8.1
true
true
@@ -724,7 +740,7 @@
org.apache.maven.plugins
maven-surefire-plugin
- 2.22.2
+ 3.1.2
@@ -744,10 +760,6 @@
${jmeter.version}
provided
-
- org.apache.jmeter
- jorphan
-
org.apache.logging.log4j
log4j-slf4j-impl
@@ -779,13 +791,16 @@
org.apache.maven.plugins
maven-shade-plugin
- 2.4.2
+ 3.2.4
org/apache/jmeter/jmeter.properties
+
+ *.proto
+
${project.artifactId}-${project.version}
@@ -814,10 +829,6 @@
ApacheJMeter_java
${jmeter.version}
-
- org.apache.jmeter
- jorphan
-
org.apache.logging.log4j
log4j-slf4j-impl
diff --git a/src/main/java/com/sngular/kloadgen/config/schemaregistry/SchemaRegistryConfigElement.java b/src/main/java/com/sngular/kloadgen/config/schemaregistry/SchemaRegistryConfigElement.java
index cdcc7490..f586de45 100644
--- a/src/main/java/com/sngular/kloadgen/config/schemaregistry/SchemaRegistryConfigElement.java
+++ b/src/main/java/com/sngular/kloadgen/config/schemaregistry/SchemaRegistryConfigElement.java
@@ -6,10 +6,6 @@
package com.sngular.kloadgen.config.schemaregistry;
-import static com.sngular.kloadgen.config.schemaregistry.SchemaRegistryConfigElementValue.SCHEMA_REGISTRY_NAME;
-import static com.sngular.kloadgen.config.schemaregistry.SchemaRegistryConfigElementValue.SCHEMA_REGISTRY_PROPERTIES;
-import static com.sngular.kloadgen.config.schemaregistry.SchemaRegistryConfigElementValue.SCHEMA_REGISTRY_URL;
-
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -83,7 +79,7 @@ private void serializeProperties() {
private Map getProperties() {
final Map result = new HashMap<>();
- final JMeterProperty property = getProperty(SCHEMA_REGISTRY_PROPERTIES);
+ final JMeterProperty property = getProperty(SchemaRegistryConfigElementValue.SCHEMA_REGISTRY_PROPERTIES);
if (Objects.nonNull(property)) {
result.putAll(
this.fromTestElementToPropertiesMap((List) property.getObjectValue()));
@@ -94,7 +90,7 @@ private Map getProperties() {
}
private String getRegistryName() {
- String registryName = getPropertyAsString(SCHEMA_REGISTRY_NAME);
+ String registryName = getPropertyAsString(SchemaRegistryConfigElementValue.SCHEMA_REGISTRY_NAME);
if (StringUtils.isBlank(registryName)) {
registryName = this.schemaRegistryName;
}
@@ -102,7 +98,7 @@ private String getRegistryName() {
}
private String getRegistryUrl() {
- String registryUrl = getPropertyAsString(SCHEMA_REGISTRY_URL);
+ String registryUrl = getPropertyAsString(SchemaRegistryConfigElementValue.SCHEMA_REGISTRY_URL);
if (StringUtils.isBlank(registryUrl)) {
registryUrl = this.schemaRegistryUrl;
}
diff --git a/src/main/java/com/sngular/kloadgen/config/schemaregistry/SchemaRegistryConfigElementBeanInfo.java b/src/main/java/com/sngular/kloadgen/config/schemaregistry/SchemaRegistryConfigElementBeanInfo.java
index cc90a49c..772fe2c6 100644
--- a/src/main/java/com/sngular/kloadgen/config/schemaregistry/SchemaRegistryConfigElementBeanInfo.java
+++ b/src/main/java/com/sngular/kloadgen/config/schemaregistry/SchemaRegistryConfigElementBeanInfo.java
@@ -6,10 +6,6 @@
package com.sngular.kloadgen.config.schemaregistry;
-import static com.sngular.kloadgen.config.schemaregistry.SchemaRegistryConfigElementValue.SCHEMA_REGISTRY_NAME;
-import static com.sngular.kloadgen.config.schemaregistry.SchemaRegistryConfigElementValue.SCHEMA_REGISTRY_PROPERTIES;
-import static com.sngular.kloadgen.config.schemaregistry.SchemaRegistryConfigElementValue.SCHEMA_REGISTRY_URL;
-
import java.beans.PropertyDescriptor;
import com.sngular.kloadgen.model.PropertyMapping;
@@ -26,22 +22,23 @@ public SchemaRegistryConfigElementBeanInfo() {
super(SchemaRegistryConfigElement.class);
- createPropertyGroup("schema_registry_config", new String[]{SCHEMA_REGISTRY_NAME, SCHEMA_REGISTRY_URL, SCHEMA_REGISTRY_PROPERTIES});
+ createPropertyGroup("schema_registry_config", new String[]{SchemaRegistryConfigElementValue.SCHEMA_REGISTRY_NAME, SchemaRegistryConfigElementValue.SCHEMA_REGISTRY_PROPERTIES,
+ SchemaRegistryConfigElementValue.SCHEMA_REGISTRY_URL});
- final PropertyDescriptor schemaRegistryName = property(SCHEMA_REGISTRY_NAME);
+ final PropertyDescriptor schemaRegistryName = property(SchemaRegistryConfigElementValue.SCHEMA_REGISTRY_NAME);
schemaRegistryName.setPropertyEditorClass(SchemaRegistryNamePropertyEditor.class);
schemaRegistryName.setValue(NOT_UNDEFINED, Boolean.TRUE);
schemaRegistryName.setValue(DEFAULT, SchemaRegistryKeyHelper.SCHEMA_REGISTRY_NAME_DEFAULT);
schemaRegistryName.setValue(NOT_EXPRESSION, Boolean.FALSE);
- final PropertyDescriptor schemaRegistryUrl = property(SCHEMA_REGISTRY_URL);
+ final PropertyDescriptor schemaRegistryUrl = property(SchemaRegistryConfigElementValue.SCHEMA_REGISTRY_URL);
schemaRegistryUrl.setPropertyEditorClass(SchemaRegistryConfigPropertyEditor.class);
schemaRegistryUrl.setValue(NOT_UNDEFINED, Boolean.TRUE);
schemaRegistryUrl.setValue(DEFAULT, SchemaRegistryKeyHelper.SCHEMA_REGISTRY_URL_DEFAULT);
schemaRegistryUrl.setValue(NOT_EXPRESSION, Boolean.FALSE);
final TypeEditor tableEditor = TypeEditor.TableEditor;
- final PropertyDescriptor tableProperties = property(SCHEMA_REGISTRY_PROPERTIES, tableEditor);
+ final PropertyDescriptor tableProperties = property(SchemaRegistryConfigElementValue.SCHEMA_REGISTRY_PROPERTIES, tableEditor);
tableProperties.setValue(TableEditor.CLASSNAME, PropertyMapping.class.getName());
tableProperties.setValue(TableEditor.HEADERS, new String[]{"Property Name", "Property Value"});
tableProperties.setValue(TableEditor.OBJECT_PROPERTIES, new String[]{PropertyMapping.PROPERTY_NAME, PropertyMapping.PROPERTY_VALUE});
diff --git a/src/main/java/com/sngular/kloadgen/config/schemaregistry/SchemaRegistryConfigElementValue.java b/src/main/java/com/sngular/kloadgen/config/schemaregistry/SchemaRegistryConfigElementValue.java
index 153418d4..8aeae711 100644
--- a/src/main/java/com/sngular/kloadgen/config/schemaregistry/SchemaRegistryConfigElementValue.java
+++ b/src/main/java/com/sngular/kloadgen/config/schemaregistry/SchemaRegistryConfigElementValue.java
@@ -1,8 +1,11 @@
package com.sngular.kloadgen.config.schemaregistry;
-public interface SchemaRegistryConfigElementValue {
+public final class SchemaRegistryConfigElementValue {
- String SCHEMA_REGISTRY_NAME = "schemaRegistryName";
- String SCHEMA_REGISTRY_URL = "schemaRegistryUrl";
- String SCHEMA_REGISTRY_PROPERTIES = "schemaRegistryProperties";
+ public static final String SCHEMA_REGISTRY_NAME = "schemaRegistryName";
+ public static final String SCHEMA_REGISTRY_URL = "schemaRegistryUrl";
+ public static final String SCHEMA_REGISTRY_PROPERTIES = "schemaRegistryProperties";
+
+ private SchemaRegistryConfigElementValue() {
+ }
}
diff --git a/src/main/java/com/sngular/kloadgen/extractor/SchemaExtractor.java b/src/main/java/com/sngular/kloadgen/extractor/SchemaExtractor.java
index 67c7977b..a7a7b760 100644
--- a/src/main/java/com/sngular/kloadgen/extractor/SchemaExtractor.java
+++ b/src/main/java/com/sngular/kloadgen/extractor/SchemaExtractor.java
@@ -12,20 +12,18 @@
import com.sngular.kloadgen.extractor.extractors.ExtractorFactory;
import com.sngular.kloadgen.model.FieldValueMapping;
import io.confluent.kafka.schemaregistry.ParsedSchema;
+import lombok.Getter;
import org.apache.commons.lang3.tuple.Pair;
-public class SchemaExtractor {
+@Getter
+public final class SchemaExtractor {
private SchemaRegistryEnum type;
public SchemaExtractor() {
}
- public SchemaRegistryEnum getType(){
- return type;
- }
-
- public void setType(SchemaRegistryEnum type){
+ public void setType(final SchemaRegistryEnum type) {
this.type = type;
}
@@ -34,11 +32,11 @@ public static Pair> flatPropertiesList(final Str
}
public static List flatPropertiesList(final ParsedSchema parserSchema) {
- return ExtractorFactory.getExtractor(parserSchema.schemaType(), "CONFLUENT").processSchema(parserSchema, SchemaRegistryEnum.CONFLUENT);
+ return ExtractorFactory.getExtractor(parserSchema.schemaType()).processSchema(parserSchema, SchemaRegistryEnum.CONFLUENT);
}
- public static List schemaTypesList(final File schemaFile, final String schemaType, String registry) throws IOException {
- return ExtractorFactory.getExtractor(schemaType, registry).getSchemaNameList(readLineByLine(schemaFile.getPath()),
+ public static List schemaTypesList(final File schemaFile, final String schemaType, final String registry) throws IOException {
+ return ExtractorFactory.getExtractor(schemaType).getSchemaNameList(readLineByLine(schemaFile.getPath()),
ExtractorFactory.getSchemaRegistry(registry));
}
@@ -52,8 +50,4 @@ private static String readLineByLine(final String filePath) throws IOException {
return contentBuilder.toString();
}
- private static List processSchema(final ParsedSchema schema) {
- return ExtractorFactory.getExtractor(schema.schemaType(),SchemaRegistryEnum.CONFLUENT.name()).processSchema(schema.rawSchema().toString(), SchemaRegistryEnum.CONFLUENT);
- }
-
}
diff --git a/src/main/java/com/sngular/kloadgen/extractor/extractors/ExtractorFactory.java b/src/main/java/com/sngular/kloadgen/extractor/extractors/ExtractorFactory.java
index 3c1e143b..371d2de4 100644
--- a/src/main/java/com/sngular/kloadgen/extractor/extractors/ExtractorFactory.java
+++ b/src/main/java/com/sngular/kloadgen/extractor/extractors/ExtractorFactory.java
@@ -12,8 +12,8 @@
import com.sngular.kloadgen.extractor.extractors.json.JsonExtractor;
import com.sngular.kloadgen.extractor.extractors.protobuff.ProtobuffExtractor;
import com.sngular.kloadgen.model.FieldValueMapping;
-import com.sngular.kloadgen.schemaregistry.adapter.impl.ApicurioParsedSchemaMetadata;
-import com.sngular.kloadgen.schemaregistry.adapter.impl.ParsedSchemaAdapter;
+import com.sngular.kloadgen.schemaregistry.adapter.impl.AbstractParsedSchemaAdapter;
+import com.sngular.kloadgen.schemaregistry.adapter.impl.ApicurioAbstractParsedSchemaMetadata;
import com.sngular.kloadgen.util.JMeterHelper;
import com.sngular.kloadgen.util.SchemaRegistryKeyHelper;
import org.apache.commons.lang3.EnumUtils;
@@ -21,30 +21,28 @@
import org.apache.jmeter.threads.JMeterContextService;
public final class ExtractorFactory {
- private static AvroExtractor avroExtractor = new AvroExtractor();
+ private static final AvroExtractor AVRO_EXTRACTOR = new AvroExtractor();
- private static JsonExtractor jsonExtractor = new JsonExtractor();
+ private static final JsonExtractor JSON_EXTRACTOR = new JsonExtractor();
- private static ProtobuffExtractor protobuffExtractor = new ProtobuffExtractor();
+ private static final ProtobuffExtractor PROTOBUFF_EXTRACTOR = new ProtobuffExtractor();
private ExtractorFactory() {
}
- public static ExtractorRegistry getExtractor(final String schemaType, final String schemaRegistryEnum) {
-
- SchemaRegistryEnum registryEnum = getSchemaRegistry(schemaRegistryEnum);
+ public static ExtractorRegistry getExtractor(final String schemaType) {
if (schemaType != null && EnumUtils.isValidEnum(SchemaTypeEnum.class, schemaType.toUpperCase())) {
final ExtractorRegistry response;
switch (SchemaTypeEnum.valueOf(schemaType.toUpperCase())) {
case JSON:
- response = jsonExtractor;
+ response = JSON_EXTRACTOR;
break;
case AVRO:
- response = avroExtractor;
+ response = AVRO_EXTRACTOR;
break;
case PROTOBUF:
- response = protobuffExtractor;
+ response = PROTOBUFF_EXTRACTOR;
break;
default:
throw new KLoadGenException(String.format("Schema type not supported %s", schemaType));
@@ -55,7 +53,7 @@ public static ExtractorRegistry getExtractor(final String schemaType, final Stri
}
}
- public static SchemaRegistryEnum getSchemaRegistry(String schemaRegistryEnum) {
+ public static SchemaRegistryEnum getSchemaRegistry(final String schemaRegistryEnum) {
if (schemaRegistryEnum != null && EnumUtils.isValidEnum(SchemaRegistryEnum.class, schemaRegistryEnum.toUpperCase())) {
return SchemaRegistryEnum.valueOf(schemaRegistryEnum.toUpperCase());
} else {
@@ -67,27 +65,20 @@ public static Pair> flatPropertiesList(final Str
final Properties properties = JMeterContextService.getContext().getProperties();
final var schemaParsed = JMeterHelper.getParsedSchema(subjectName, properties);
final String registryName = properties.getProperty(SchemaRegistryKeyHelper.SCHEMA_REGISTRY_NAME);
- String schemaType = null;
- final ParsedSchemaAdapter parsedSchemaAdapter = schemaParsed.getParsedSchemaAdapter();
- schemaType = parsedSchemaAdapter.getType();
+ final AbstractParsedSchemaAdapter abstractParsedSchemaAdapter = schemaParsed.getParsedSchemaAdapter();
+ final String schemaType = abstractParsedSchemaAdapter.getType();
- List attributeList = new ArrayList<>();
- SchemaRegistryEnum schemaRegistryEnum = SchemaRegistryEnum.valueOf(registryName.toUpperCase());
+ final List attributeList = new ArrayList<>();
+ final SchemaRegistryEnum schemaRegistryEnum = SchemaRegistryEnum.valueOf(registryName.toUpperCase());
- Object schema = null;
+ final Object schema;
if (Objects.nonNull(registryName)) {
//TODO change parser
- switch (schemaRegistryEnum) {
- case APICURIO:
- schema = ((ApicurioParsedSchemaMetadata) parsedSchemaAdapter).getSchema();
- break;
- case CONFLUENT:
- schema = parsedSchemaAdapter.getRawSchema();
- break;
- default:
- throw new KLoadGenException("Schema Registry Type nos supported " + registryName.toUpperCase());
- }
- attributeList = getExtractor(schemaType,registryName.toUpperCase()).processSchema(schema, schemaRegistryEnum);
+ schema = switch (schemaRegistryEnum) {
+ case APICURIO -> ((ApicurioAbstractParsedSchemaMetadata) abstractParsedSchemaAdapter).getSchema();
+ case CONFLUENT -> abstractParsedSchemaAdapter.getRawSchema();
+ };
+ attributeList.addAll(getExtractor(schemaType).processSchema(schema, schemaRegistryEnum));
}
return Pair.of(schemaType, attributeList);
}
diff --git a/src/main/java/com/sngular/kloadgen/extractor/extractors/avro/AbstractAvroFileExtractor.java b/src/main/java/com/sngular/kloadgen/extractor/extractors/avro/AbstractAvroFileExtractor.java
index 882c068e..b79d2d6e 100644
--- a/src/main/java/com/sngular/kloadgen/extractor/extractors/avro/AbstractAvroFileExtractor.java
+++ b/src/main/java/com/sngular/kloadgen/extractor/extractors/avro/AbstractAvroFileExtractor.java
@@ -23,7 +23,7 @@ public abstract class AbstractAvroFileExtractor {
protected AbstractAvroFileExtractor() {
}
- public List processSchemaDefault(final Schema schemaReceived) {
+ public final List processSchemaDefault(final Schema schemaReceived) {
final var attributeList = new ArrayList();
Schema aux = null;
if (checkIfUnion(schemaReceived)) {
@@ -31,19 +31,17 @@ public List processSchemaDefault(final Schema schemaReceived)
} else if (checkIfRecord(schemaReceived)) {
aux = schemaReceived;
}
- if(aux != null && (checkIfUnion(schemaReceived) || checkIfRecord(schemaReceived))){
+ if (aux != null && (checkIfUnion(schemaReceived) || checkIfRecord(schemaReceived))) {
aux.getFields().forEach(field -> processField(field, attributeList, true, true));
}
return attributeList;
}
- public List getSchemaNameList(Schema schema) {
- List result = new ArrayList<>();
- result.addAll(extractSchemaNames(schema));
- return result;
+ public final List getSchemaNameList(final Schema schema) {
+ return new ArrayList<>(extractSchemaNames(schema));
}
- public void processField(
+ public final void processField(
final Schema.Field innerField, final List completeFieldList, final boolean isAncestorRequired, final boolean isAncestor) {
if (checkIfRecord(innerField.schema())) {
processRecordFieldList(innerField.name(), ".", processFieldList(innerField.schema().getFields(), isAncestorRequired), completeFieldList);
@@ -354,8 +352,8 @@ private boolean checkIfRequiredField(final Schema innerSchema) {
return result;
}
- private Set extractSchemaNames(Schema schema) {
- Set schemaNames = new HashSet<>();
+ private Set extractSchemaNames(final Schema schema) {
+ final Set schemaNames = new HashSet<>();
if (checkIfRecord(schema)) {
schemaNames.add(schema.getName());
} else if (checkIfArray(schema)) {
diff --git a/src/main/java/com/sngular/kloadgen/extractor/extractors/avro/AvroExtractor.java b/src/main/java/com/sngular/kloadgen/extractor/extractors/avro/AvroExtractor.java
index 677b36db..88e48b8d 100644
--- a/src/main/java/com/sngular/kloadgen/extractor/extractors/avro/AvroExtractor.java
+++ b/src/main/java/com/sngular/kloadgen/extractor/extractors/avro/AvroExtractor.java
@@ -1,8 +1,5 @@
package com.sngular.kloadgen.extractor.extractors.avro;
-import static com.sngular.kloadgen.common.SchemaRegistryEnum.APICURIO;
-import static com.sngular.kloadgen.common.SchemaRegistryEnum.CONFLUENT;
-
import java.util.List;
import java.util.Map;
@@ -13,14 +10,14 @@
public class AvroExtractor implements ExtractorRegistry