Skip to content

Commit

Permalink
#332 Fix styles and test
Browse files Browse the repository at this point in the history
  • Loading branch information
jemacineiras committed Oct 3, 2023
1 parent a442f7a commit 8b8e936
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public static Pair<String, List<FieldValueMapping>> flatPropertiesList(final Str
schema = switch (schemaRegistryEnum) {
case APICURIO -> ((ApicurioAbstractParsedSchemaMetadata) abstractParsedSchemaAdapter).getSchema();
case CONFLUENT -> abstractParsedSchemaAdapter.getRawSchema();
default -> throw new KLoadGenException("Schema Registry Type nos supported " + registryName.toUpperCase());
};
attributeList.addAll(getExtractor(schemaType).processSchema(schema, schemaRegistryEnum));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,9 @@ private List<FieldValueMapping> extractMapInternalFields(
completeFieldList.add(
FieldValueMapping.builder()
.fieldName(name)
.fieldType(value.getType() + "-map" + ((StringUtils.isNotEmpty(breadCrumb) && breadCrumb.endsWith("[:]")) ? "-map" :
(StringUtils.isNotEmpty(
breadCrumb) &&
breadCrumb.endsWith("[]"))
?
SchemaExtractorUtil.ARRAY_TYPE_POSTFIX
.fieldType(value.getType() + "-map" + ((StringUtils.isNotEmpty(breadCrumb)
&& breadCrumb.endsWith("[:]")) ? "-map"
: (StringUtils.isNotEmpty(breadCrumb) && breadCrumb.endsWith("[]")) ? SchemaExtractorUtil.ARRAY_TYPE_POSTFIX
: breadCrumb))
.required(!name.endsWith("][]") && !name.endsWith("][:]") && innerField.isFieldRequired())
.isAncestorRequired(!isRootElement && isAncestorRequired != null && isAncestorRequired)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@

public class ProtobuffExtractor implements ExtractorRegistry<Object> {

static Map<SchemaRegistryEnum, Extractor> schemaRegistryMap = Map.of(SchemaRegistryEnum.CONFLUENT, new ProtoBufConfluentExtractor(),
SchemaRegistryEnum.APICURIO, new ProtoBufApicurioExtractor());
private static final Map<SchemaRegistryEnum, Extractor> SCHEMA_REGISTRY_MAP = Map.of(SchemaRegistryEnum.CONFLUENT, new ProtoBufConfluentExtractor(),
SchemaRegistryEnum.APICURIO, new ProtoBufApicurioExtractor());

public final List<FieldValueMapping> processSchema(final Object schemaReceived, final SchemaRegistryEnum registryEnum) {
final var resultSchema = new ArrayList<FieldValueMapping>();
if (schemaReceived instanceof ProtoFileElement) {
resultSchema.addAll(schemaRegistryMap.get(SchemaRegistryEnum.APICURIO).processSchema(schemaReceived));
resultSchema.addAll(SCHEMA_REGISTRY_MAP.get(SchemaRegistryEnum.APICURIO).processSchema(schemaReceived));
} else {
resultSchema.addAll(SCHEMA_REGISTRY_MAP.get(registryEnum).processSchema(schemaReceived));
}
resultSchema.addAll(schemaRegistryMap.get(registryEnum).processSchema(schemaReceived));
return resultSchema;
}

public final List<String> getSchemaNameList(final String schema, final SchemaRegistryEnum registryEnum) {
return schemaRegistryMap.get(registryEnum).getSchemaNameList(schema);
return SCHEMA_REGISTRY_MAP.get(registryEnum).getSchemaNameList(schema);
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.sngular.kloadgen.schemaregistry.adapter.impl;

import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
public final class BaseSchemaMetadata<T extends SchemaMetadataAdapter> {

Expand All @@ -11,7 +13,4 @@ public BaseSchemaMetadata(final T schemaMetadataAdapter) {
this.schemaMetadataAdapter = schemaMetadataAdapter;
}

public T getSchemaMetadataAdapter() {
return schemaMetadataAdapter;
}
}

This file was deleted.

Loading

0 comments on commit 8b8e936

Please sign in to comment.