From 55dcb940610119cc18f54ee2601eb6edc5b760d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Enrique=20Garc=C3=ADa=20Maci=C3=B1eiras?= Date: Wed, 20 Sep 2023 00:30:50 +0200 Subject: [PATCH] get The Parser un and Running --- pom-maven-central.xml | 4 +- pom.xml | 21 +--------- .../config/asyncapi/AsyncApiConfigGui.java | 41 +++++++++++-------- .../extractor/model/AsyncApiSchema.java | 7 ++++ .../kloadgen/sampler/AsyncApiSampler.java | 2 +- 5 files changed, 36 insertions(+), 39 deletions(-) diff --git a/pom-maven-central.xml b/pom-maven-central.xml index 99f802f9..6320419b 100644 --- a/pom-maven-central.xml +++ b/pom-maven-central.xml @@ -7,7 +7,7 @@ kloadgen - 5.6.5 + 5.7.0 KLoadGen Load Generation Jmeter plugin for Kafka Cluster. Supporting AVRO, JSON Schema and Protobuf schema types. Generate Artificial @@ -307,7 +307,7 @@ 4.4 3.12.0 2.8.6 - 31.0.1-jre + 32.0.0-jre 2.4.0-b180830.0359 11 provided diff --git a/pom.xml b/pom.xml index dc370f90..74286d73 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ kloadgen - 5.6.5 + 5.7.0 KLoadGen Load Generation Jmeter plugin for Kafka Cluster. Supporting AVRO, JSON Schema and Protobuf schema types. Generate Artificial @@ -317,17 +317,6 @@ - - org.apache.jmeter - jorphan - ${jmeter.version} - - - org.slf4j - slf4j-api - - - org.apache.kafka kafka-clients @@ -721,10 +710,6 @@ ${jmeter.version} provided - - org.apache.jmeter - jorphan - org.apache.logging.log4j log4j-slf4j-impl @@ -791,10 +776,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/asyncapi/AsyncApiConfigGui.java b/src/main/java/com/sngular/kloadgen/config/asyncapi/AsyncApiConfigGui.java index 5c4a52ef..450915c5 100644 --- a/src/main/java/com/sngular/kloadgen/config/asyncapi/AsyncApiConfigGui.java +++ b/src/main/java/com/sngular/kloadgen/config/asyncapi/AsyncApiConfigGui.java @@ -13,7 +13,6 @@ package com.sngular.kloadgen.config.asyncapi; import java.awt.BorderLayout; -import java.awt.Component; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.GridBagConstraints; @@ -23,6 +22,13 @@ import java.util.List; import java.util.Objects; +import com.sngular.kloadgen.extractor.ApiExtractor; +import com.sngular.kloadgen.extractor.asyncapi.AsyncApiExtractorImpl; +import com.sngular.kloadgen.extractor.model.AsyncApiAbstract; +import com.sngular.kloadgen.extractor.model.AsyncApiSchema; +import com.sngular.kloadgen.extractor.model.AsyncApiServer; +import com.sngular.kloadgen.model.FieldValueMapping; +import com.sngular.kloadgen.sampler.AsyncApiSampler; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JComboBox; @@ -35,13 +41,6 @@ import javax.swing.border.TitledBorder; import javax.swing.filechooser.FileSystemView; import javax.swing.table.DefaultTableModel; - -import com.sngular.kloadgen.extractor.ApiExtractor; -import com.sngular.kloadgen.extractor.asyncapi.AsyncApiExtractorImpl; -import com.sngular.kloadgen.extractor.model.AsyncApiAbstract; -import com.sngular.kloadgen.extractor.model.AsyncApiSchema; -import com.sngular.kloadgen.extractor.model.AsyncApiServer; -import com.sngular.kloadgen.sampler.AsyncApiSampler; import org.apache.jmeter.samplers.gui.AbstractSamplerGui; import org.apache.jmeter.testelement.TestElement; import org.apache.jmeter.util.JMeterUtils; @@ -167,6 +166,18 @@ private void fillTable(final DefaultTableModel sche } } + private void fillTable(final DefaultTableModel schemaFields, final Object[] schemaData) { + if (Objects.nonNull(schemaData)) { + final var count = schemaFields.getRowCount(); + for (var i = 0; i < count; i++) { + schemaFields.removeRow(0); + } + for (var data : schemaData) { + schemaFields.addRow(((FieldValueMapping) data).getProperties()); + } + } + } + private Object[] dataToRow(final T data) { return data.getProperties(); } @@ -219,21 +230,19 @@ private JPanel createRegistryTab() { private JPanel createSchemaTab() { final JPanel schemaTab = new JPanel(); - schemaTab.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); + schemaTab.setLayout(new BorderLayout(5, 5)); topicComboBox = new JComboBox<>(); topicComboBox.setRenderer(new ApiSchemaRenderer()); + topicComboBox.addActionListener(this::topicComboActionListener); schemaTab.add(topicComboBox); schemaTab.add(new JTable(schemaFieldModel)); return schemaTab; } - private static Component getComponentProperty(final String property) { - return new Component() { - @Override - public String getName() { - return property; - } - }; + private void topicComboActionListener(final ActionEvent event) { + final JComboBox cb = (JComboBox)event.getSource(); + final var selectedSchema = (AsyncApiSchema) cb.getSelectedItem(); + fillTable(schemaFieldModel, selectedSchema.getProperties()); } @Override diff --git a/src/main/java/com/sngular/kloadgen/extractor/model/AsyncApiSchema.java b/src/main/java/com/sngular/kloadgen/extractor/model/AsyncApiSchema.java index 810f1236..3537cd33 100644 --- a/src/main/java/com/sngular/kloadgen/extractor/model/AsyncApiSchema.java +++ b/src/main/java/com/sngular/kloadgen/extractor/model/AsyncApiSchema.java @@ -1,12 +1,14 @@ package com.sngular.kloadgen.extractor.model; import java.util.List; + import com.sngular.kloadgen.model.FieldValueMapping; import lombok.Builder; import lombok.Value; @Value @Builder + public class AsyncApiSchema implements AsyncApiAbstract { String topicName; @@ -23,4 +25,9 @@ public class AsyncApiSchema implements AsyncApiAbstract { public Object[] getProperties() { return model.toArray(); } + + @Override + public String toString() { + return topicName; + } } diff --git a/src/main/java/com/sngular/kloadgen/sampler/AsyncApiSampler.java b/src/main/java/com/sngular/kloadgen/sampler/AsyncApiSampler.java index 8c475714..9add0f2c 100644 --- a/src/main/java/com/sngular/kloadgen/sampler/AsyncApiSampler.java +++ b/src/main/java/com/sngular/kloadgen/sampler/AsyncApiSampler.java @@ -14,7 +14,7 @@ public class AsyncApiSampler extends AbstractSampler implements Serializable { @Override - public boolean applies(final ConfigTestElement configElement) { + public final boolean applies(final ConfigTestElement configElement) { return super.applies(configElement); }