Skip to content

Commit

Permalink
Made Megalinter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
KristianTrifork committed Dec 5, 2023
1 parent d14d942 commit b09c754
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package cheetah.exmaple.job;

import cheetah.exmaple.model.avrorecord.InputEventAvro;
import cheetah.exmaple.model.avrorecord.OutputEventAvro;
import cheetah.exmaple.model.json.InputEvent;
import com.trifork.cheetah.processing.connector.kafka.config.CheetahKafkaSourceConfig;
Expand All @@ -14,14 +13,12 @@

import java.io.Serializable;

import java.io.Serializable;

/** jsonToAvroJob sets up the data processing job. */
public class jsonToAvroJob extends Job implements Serializable {
public class JsonToAvroJob extends Job implements Serializable {

@SuppressWarnings("PMD.SignatureDeclareThrowsException") // Fix once lib-processing is fixed
public static void main(final String[] args) throws Exception {
new jsonToAvroJob().start(args);
new JsonToAvroJob().start(args);
}

@Override
Expand All @@ -35,7 +32,7 @@ protected void setup() {

// Transform stream
final SingleOutputStreamOperator<OutputEventAvro> outputStream =
inputStream.map(new jsonToAvroMapper("ExtraFieldValue"));
inputStream.map(new JsonToAvroMapper("ExtraFieldValue"));

// Output sink
KafkaSink<OutputEventAvro> kafkaSink = CheetahKafkaSink.avroSpecificBuilder(OutputEventAvro.class, this)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package cheetah.exmaple.job;

import cheetah.exmaple.model.avrorecord.InputEventAvro;
import cheetah.exmaple.model.avrorecord.OutputEventAvro;
import cheetah.exmaple.model.json.InputEvent;
import org.apache.flink.api.common.functions.MapFunction;

/** jsonToAvroMapper converts from InputEvent to OutputEvent. */
public class jsonToAvroMapper implements MapFunction<InputEvent, OutputEventAvro> {
public class JsonToAvroMapper implements MapFunction<InputEvent, OutputEventAvro> {
private final String extraField;

public jsonToAvroMapper(final String extraField) {
public JsonToAvroMapper(final String extraField) {
this.extraField = extraField;
}

@Override
public OutputEventAvro map(final InputEvent InputEvent) {
return new OutputEventAvro(InputEvent.getDeviceId(), InputEvent.getValue(), InputEvent.getTimestamp(), extraField);
public OutputEventAvro map(final InputEvent inputEvent) {
return new OutputEventAvro(inputEvent.getDeviceId(), inputEvent.getValue(), inputEvent.getTimestamp(), extraField);
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package cheetah.exmaple.job;

import cheetah.exmaple.model.avrorecord.InputEventAvro;
import cheetah.exmaple.model.json.InputEvent;
import org.junit.jupiter.api.Test;

import java.util.UUID;

import static org.junit.jupiter.api.Assertions.assertEquals;

class jsonToAvroMapperTest {
private final jsonToAvroMapper mapper = new jsonToAvroMapper("extraFieldValue");
class JsonToAvroMapperTest {
private final JsonToAvroMapper mapper = new JsonToAvroMapper("extraFieldValue");

@Test
public void testEnrichment() {
Expand Down

0 comments on commit b09c754

Please sign in to comment.