Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
chore: decouple the internal model names from the generated JSON (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
kayman-mk authored May 12, 2022
1 parent 45a839d commit e16f132
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 3 deletions.
44 changes: 41 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<scm>
<connection>scm:git:git://github.com/Hapag-Lloyd/dist-comm-vis.git</connection>
<developerConnection>scm:git:ssh://github.com:Hapag-Lloyd/dist-comm-vis.git</developerConnection>
<developerConnection>scm:git:ssh://gitHub.com:Hapag-Lloyd/dist-comm-vis.git</developerConnection>
<url>https://github.com/Hapag-Lloyd/dist-comm-vis/tree/main</url>
</scm>

Expand Down Expand Up @@ -81,8 +81,6 @@
</profile>
</profiles>
<build>
<sourceDirectory>src/java/main</sourceDirectory>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -138,10 +136,50 @@
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version>
</plugin>
</plugins>
</build>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.8.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.9.0</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.22.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hlag.tools.commvis.analyzer.model;

import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;
Expand All @@ -19,14 +20,19 @@ public class CommunicationModel {
/**
* Identifier for the current project, e.g. gitlab project id
*/
@SerializedName(value="projectId")
private String projectId;

/**
* A name for the project. Just for information.
*/
@SerializedName(value="projectName")
private String projectName;

/**
* All sender and receiver endpoints found.
*/
@SerializedName(value="endpoints")
private Collection<ISenderReceiverCommunication> endpoints;

public void visit(AbstractCommunicationModelVisitor visitor) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
package com.hlag.tools.commvis.analyzer.model;

import com.google.gson.annotations.SerializedName;
import lombok.*;

/**
* An endpoint which can receive http(s) messages. Typically, a REST API.
*/
@Value
public class HttpConsumer implements ISenderReceiverCommunication {
@SerializedName(value="className")
private final String className;
@SerializedName(value="methodName")
private final String methodName;

@SerializedName(value="type")
private final String type;
@SerializedName(value="path")
private final String path;

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hlag.tools.commvis.analyzer.model;

import com.google.gson.annotations.SerializedName;
import lombok.Value;

/**
Expand All @@ -10,23 +11,31 @@ public class HttpProducer implements ISenderReceiverCommunication {
/**
* The full qualified classname where the producer lives.
*/
@SerializedName(value="className")
private final String className;

/**
* The method name of the producer.
*/
@SerializedName(value="methodName")
private final String methodName;

/**
* The HTTP method like GET or POST.
*/
@SerializedName(value="type")
private final String type;

/**
* The full path name called (usually without a domain).
*/
@SerializedName(value="path")
private final String path;

/**
* The project id of the referenced project.
*/
@SerializedName(value="destinationProjectId")
private final String destinationProjectId;

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hlag.tools.commvis.analyzer.model;

import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand All @@ -13,10 +14,15 @@
@ToString
@EqualsAndHashCode
public class JmsReceiver implements ISenderReceiverCommunication {
@SerializedName(value="className")
private String className;

// e.g. "javax.jms.Queue"
@SerializedName(value="destinationType")
private String destinationType;

// e.g. "jms/catalogs/customer"
@SerializedName(value="destination")
private String destination;

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.hlag.tools.commvis.analyzer.model;

import com.google.gson.annotations.SerializedName;
import org.junit.jupiter.api.Test;

import java.lang.reflect.Field;

import static org.assertj.core.api.Assertions.assertThat;

class CommunicationModelTest {
@Test
void shouldHaveSerializedNameAnnotationOnFiled_toDecoupleTheFieldNameFromJson() {
Field[] declaredFields = CommunicationModel.class.getDeclaredFields();

for (Field f : declaredFields) {
SerializedName actualAnnotation = f.getAnnotation(SerializedName.class);

assertThat(actualAnnotation).isNotNull();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.hlag.tools.commvis.analyzer.model;

import com.google.gson.annotations.SerializedName;
import org.junit.jupiter.api.Test;

import java.lang.reflect.Field;

import static org.assertj.core.api.Assertions.assertThat;

class HttpConsumerTest {
@Test
void shouldHaveSerializedNameAnnotationOnFiled_toDecoupleTheFieldNameFromJson() {
Field[] declaredFields = CommunicationModel.class.getDeclaredFields();

for (Field f : declaredFields) {
SerializedName actualAnnotation = f.getAnnotation(SerializedName.class);

assertThat(actualAnnotation).isNotNull();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.hlag.tools.commvis.analyzer.model;

import com.google.gson.annotations.SerializedName;
import org.junit.jupiter.api.Test;

import java.lang.reflect.Field;

import static org.assertj.core.api.Assertions.assertThat;

class HttpProducerTest {
@Test
void shouldHaveSerializedNameAnnotationOnFiled_toDecoupleTheFieldNameFromJson() {
Field[] declaredFields = CommunicationModel.class.getDeclaredFields();

for (Field f : declaredFields) {
SerializedName actualAnnotation = f.getAnnotation(SerializedName.class);

assertThat(actualAnnotation).isNotNull();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.hlag.tools.commvis.analyzer.model;

import com.google.gson.annotations.SerializedName;
import org.junit.jupiter.api.Test;

import java.lang.reflect.Field;

import static org.assertj.core.api.Assertions.assertThat;

class JmsReceiverTest {
@Test
void shouldHaveSerializedNameAnnotationOnFiled_toDecoupleTheFieldNameFromJson() {
Field[] declaredFields = CommunicationModel.class.getDeclaredFields();

for (Field f : declaredFields) {
SerializedName actualAnnotation = f.getAnnotation(SerializedName.class);

assertThat(actualAnnotation).isNotNull();
}
}
}

0 comments on commit e16f132

Please sign in to comment.