Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@
"java.test.config": {
"name": "Allow Reflection",
"vmArgs": ["--add-opens", "java.base/java.time=ALL-UNNAMED"] // allows the ValidateSdx tests, which use reflection, to run
}
},
"coverage-gutters.coverageFileNames": [
"jacoco.xml"
],
"coverage-gutters.coverageBaseDir": "**/target/site/jacoco"
}
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,28 +98,28 @@ This will create the `target` folder under each module. From here, create a new
```
.
├── cv-data-controller
│ ├── cv-data-controller-x.x.x.jar
│ ├── cv-data-controller-x.y.z.jar
│ ├── Dockerfile
├── cv-data-tasks
│ ├── cv-data-tasks-x.x.x.jar
│ ├── cv-data-tasks-x.y.z.jar
│ ├── Dockerfile
├── docker-compose.yml
├── ode-data-logger
│ ├── Dockerfile
│ ├── ode-data-logger-x.x.x.jar
│ ├── ode-data-logger-x.y.z.jar
├── ode-mongo-logger
│ ├── Dockerfile
│ ├── ode-mongo-logger-x.x.x.jar
│ ├── ode-mongo-logger-x.y.z.jar
├── ode-wrapper
│ ├── Dockerfile
│ ├── ode-wrapper-x.x.x.jar
│ ├── ode-wrapper-x.y.z.jar
├── ode-wrapper-docs
│ └── swagger-ui-master
│ ├── Dockerfile
│ ├── (swagger folder structure)
└── tim-refresh
├── Dockerfile
├── tim-refresh-x.x.x.jar
├── tim-refresh-x.y.z.jar

```

Expand Down
6 changes: 3 additions & 3 deletions cert-expiration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ The following instructions are intended to be executed from the root directory o

Linux:
```bash
mv ./cert-expiration/target/cert-expiration-x.x.x-SNAPSHOT.jar ./cert-expiration/
mv ./cert-expiration/target/cert-expiration-x.y.z-SNAPSHOT.jar ./cert-expiration/
```
Windows:
```windows
move .\cert-expiration\target\cert-expiration-x.x.x-SNAPSHOT.jar .\cert-expiration\
move .\cert-expiration\target\cert-expiration-x.y.z-SNAPSHOT.jar .\cert-expiration\
```

Replace `x.x.x` with the version number of the JAR file. If a JAR file already exists in the `cert-expiration` directory, you may need to delete it first.
Replace `x.y.z` with the version number of the JAR file. If a JAR file already exists in the `cert-expiration` directory, you may need to delete it first.

1. Copy the sample.env to .env:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,35 @@
import com.trihydro.certexpiration.controller.LoopController;
import com.trihydro.library.factory.KafkaFactory;
import com.trihydro.library.helpers.EmailHelper;
import com.trihydro.library.helpers.Utility;
import com.trihydro.library.model.TopicDataWrapper;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class CertExpirationConsumer {
private CertExpirationConfiguration configProperties;
private Utility utility;
private CertExpirationConfiguration configProperties;
private EmailHelper emailHelper;
private LoopController loopController;
private KafkaFactory kafkaFactory;

@Autowired
public CertExpirationConsumer(CertExpirationConfiguration configProperties, Utility _utility,
EmailHelper _emailHelper, LoopController _loopController, KafkaFactory _kafkaFactory)
public CertExpirationConsumer(CertExpirationConfiguration configProperties,
EmailHelper _emailHelper, LoopController _loopController, KafkaFactory _kafkaFactory)
throws IOException, Exception {
this.configProperties = configProperties;
utility = _utility;
emailHelper = _emailHelper;
loopController = _loopController;
kafkaFactory = _kafkaFactory;
}

public void startKafkaConsumer() throws Exception {
utility.logWithDate("starting..............");
var stringConsumer = kafkaFactory.createStringConsumer(configProperties.getKafkaHostServer() + ":9092",
log.info("starting..............");
var stringConsumer = kafkaFactory.createStringConsumer(configProperties.getKafkaHostServer() + ":9092",
configProperties.getDepositGroup(), configProperties.getDepositTopic());
var stringProducer = kafkaFactory.createStringProducer(configProperties.getKafkaHostServer() + ":9092");

Expand All @@ -51,9 +50,9 @@ public void startKafkaConsumer() throws Exception {
for (var record : records) {
String logTxt = String.format("Found topic %s, submitting to %s for later consumption",
record.topic(), producerTopic);
utility.logWithDate(logTxt);
log.info(logTxt);

TopicDataWrapper tdw = new TopicDataWrapper();
TopicDataWrapper tdw = new TopicDataWrapper();
tdw.setTopic(record.topic());
tdw.setData(record.value());
ProducerRecord<String, String> producerRecord = new ProducerRecord<String, String>(producerTopic,
Expand All @@ -62,8 +61,8 @@ public void startKafkaConsumer() throws Exception {
}
}
} catch (Exception ex) {
utility.logWithDate(ex.getMessage());
emailHelper.ContainerRestarted(configProperties.getAlertAddresses(), configProperties.getMailPort(),
log.info(ex.getMessage());
emailHelper.ContainerRestarted(configProperties.getAlertAddresses(), configProperties.getMailPort(),
configProperties.getMailHost(), configProperties.getFromEmail(), "Logger Kafka Consumer");
// Re-throw exception to cause container to exit and restart
throw ex;
Expand All @@ -72,7 +71,7 @@ public void startKafkaConsumer() throws Exception {
stringConsumer.close();
stringProducer.close();
} catch (Exception consumerEx) {
consumerEx.printStackTrace();
log.error("Exception", consumerEx);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.trihydro.library.helpers.EmailHelper;
import com.trihydro.library.helpers.Utility;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.MockConsumer;
import org.apache.kafka.clients.consumer.OffsetResetStrategy;
Expand All @@ -37,6 +38,7 @@
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
@Slf4j
public class CertExpirationConsumerTest {
private static final String TOPIC = "topic";
private static final String PRODUCERTOPIC = "producerTopic";
Expand All @@ -52,8 +54,6 @@ public class CertExpirationConsumerTest {
@Mock
private CertExpirationConfiguration mockConfigProperties;
@Mock
private Utility mockUtility;
@Mock
private EmailHelper mockEmailHelper;
@Mock
private LoopController mockLoopController;
Expand Down Expand Up @@ -115,11 +115,6 @@ public void startKafkaConsumer_SUCCESS() throws Exception {

// Assert
Assertions.assertEquals(1, mockProducer.history().size());

verify(mockUtility).logWithDate("starting..............");
verify(mockUtility).logWithDate("Found topic topic, submitting to producerTopic for later consumption");

verifyNoMoreInteractions(mockUtility);
Assertions.assertTrue(mockConsumer.closed());
Assertions.assertTrue(mockProducer.closed());
}
Expand All @@ -130,16 +125,11 @@ public void startKafkaConsumer_EXCEPTION() throws Exception {
configureConsumerException("Network error");

// Act
Exception ex = assertThrows(KafkaException.class, () -> uut.startKafkaConsumer());
assertThrows(KafkaException.class, () -> uut.startKafkaConsumer());

// Assert
Assertions.assertEquals("Network error", ex.getMessage());
verify(mockUtility).logWithDate("starting..............");

verify(mockUtility).logWithDate("Network error");
verify(mockEmailHelper).ContainerRestarted(any(), any(), any(), any(), any());

verifyNoMoreInteractions(mockUtility);
Assertions.assertTrue(mockConsumer.closed());
Assertions.assertTrue(mockProducer.closed());
}
Expand All @@ -156,12 +146,8 @@ public void startKafkaConsumer_DOUBLEEXCEPTION() throws Exception {
// Assert
Assertions.assertEquals("Mail Exception", ex.getMessage());

verify(mockUtility).logWithDate("starting..............");

verify(mockUtility).logWithDate("Network error");
verify(mockEmailHelper).ContainerRestarted(any(), any(), any(), any(), any());

verifyNoMoreInteractions(mockUtility);
Assertions.assertTrue(mockConsumer.closed());
Assertions.assertTrue(mockProducer.closed());
}
Expand Down
3 changes: 2 additions & 1 deletion cv-data-controller/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.jar
*.jar
*.crt
6 changes: 3 additions & 3 deletions cv-data-controller/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ The following instructions are intended to be executed from the root directory o

Linux:
```bash
mv ./cv-data-controller/target/cv-data-controller-x.x.x-SNAPSHOT.jar ./cv-data-controller/
mv ./cv-data-controller/target/cv-data-controller-x.y.z-SNAPSHOT.jar ./cv-data-controller/
```
Windows:
```windows
move .\cv-data-controller\target\cv-data-controller-x.x.x-SNAPSHOT.jar .\cv-data-controller\
move .\cv-data-controller\target\cv-data-controller-x.y.z-SNAPSHOT.jar .\cv-data-controller\
```

Replace `x.x.x` with the version number of the JAR file. If a JAR file already exists in the `cv-data-controller` directory, you may need to delete it first.
Replace `x.y.z` with the version number of the JAR file. If a JAR file already exists in the `cv-data-controller` directory, you may need to delete it first.

1. Copy the sample.env to .env:

Expand Down
19 changes: 18 additions & 1 deletion cv-data-controller/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,24 @@
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.0</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-testcontainers</artifactId>
<version>3.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>1.19.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>1.19.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<properties>
Expand Down
Loading