Skip to content

Commit

Permalink
Merge pull request #28 from usdot-jpo-ode/release_q3
Browse files Browse the repository at this point in the history
Merge Q3 Release into master
  • Loading branch information
dan-du-car authored Nov 29, 2023
2 parents 00c070f + d13f345 commit 8dfca7f
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
sonar.java.binaries=home/runner/work/jpo-sdw-depositor/jpo-sdw-depositor/target
sonar.projectName=jpo-sdw-depositor
sonar.projectKey=usdot-jpo-ode_jpo-sdw-depositor
sonar.organization=usdot-jpo-ode-1
sonar.organization=usdot-jpo-ode
jpo-sdw-depositor.sonar.projectBaseDir=home/runner/work/jpo-sdw-depositor/jpo-sdw-depositor
jpo-sdw-depositor.sonar.sources=src
jpo-sdw-depositor.sonar.tests=src/test
Expand Down
14 changes: 14 additions & 0 deletions docs/Release_notes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
Jpo-sdw-depositor Release Notes
----------------------------

Version 1.5.0, released November 2023
----------------------------------------

### **Summary**
The updates for the jpo-sdw-depositor 1.5.0 involve correcting the default SDX URL, fixing failing unit tests, and addressing a key reference issue in KafkaConsumerRestDepositor.java.
- The default SDX URL has been corrected.
- Resolved failing unit tests.
- Addressed a key reference issue in KafkaConsumerRestDepositor.java.
- Renamed mocked variables in DepositControllerTest.java

Known Issues:
- No known issues at this time.


Version 1.4.0, released July 5th 2023
----------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<properties>
<jmockit.version>1.49</jmockit.version>
<argLine>-javaagent:${user.home}/.m2/repository/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar</argLine>
<sonar.organization>usdot-jpo-ode-1</sonar.organization>
<sonar.organization>usdot-jpo-ode</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<!-- JaCoCo Properties -->
<jacoco.version>0.8.8</jacoco.version>
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/jpo/sdw/depositor/DepositorProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class DepositorProperties implements EnvironmentAware {

private static final String DEFAULT_GROUP_ID = "usdot.jpo.sdw";
private static final String DEFAULT_KAFKA_PORT = "9092";
private static final String DEFAULT_DESTINATION_URL = "https://sdx-service.trihydro.com/api/deposit";
private static final String DEFAULT_DESTINATION_URL = "https://sdx-service.trihydro.com/api/deposit-multi";
private static final String[] DEFAULT_SUBSCRIPTION_TOPICS = { "topic.SDWDepositorInput" };
private static final String DEFAULT_ENCODE_TYPE = "hex";

Expand Down Expand Up @@ -61,8 +61,9 @@ void initialize() {
if (getEncodeType() == null)
setEncodeType(DEFAULT_ENCODE_TYPE);

if (getDestinationUrl() == null)
if (getDestinationUrl() == null || getDestinationUrl().isEmpty()) {
setDestinationUrl(DEFAULT_DESTINATION_URL);
}

if (getSubscriptionTopics() == null || getSubscriptionTopics().length == 0) {
String topics = String.join(",", DEFAULT_SUBSCRIPTION_TOPICS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public KafkaConsumerRestDepositor(KafkaConsumer<String, String> kafkaConsumer, R
this.setRestDepositor(restDepositor);
this.jsonMsgList = new JSONObject();
this.jsonMsg = new JSONObject();
this.jsonMsg.put("EncodeType", encodeType);
this.jsonMsg.put("encodeType", encodeType);
}

@Override
Expand All @@ -49,8 +49,8 @@ public void run(String... topics) {
JSONArray jsonRequests = new JSONArray();
for (ConsumerRecord<String, String> record : records) {
logger.info("Depositing message {}", record);
this.jsonMsg.put("EncodedMsg", record.value());
jsonRequests.put(jsonMsg);
this.jsonMsg.put("encodedMsg", record.value());
jsonRequests.put(new JSONObject(jsonMsg.toString()));
}
if (records.count() != 0) {
this.jsonMsgList.put("depositRequests", jsonRequests);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

import jpo.sdw.depositor.DepositorProperties;
import jpo.sdw.depositor.consumerdepositors.KafkaConsumerRestDepositor;
import mockit.Capturing;
import mockit.Expectations;
import mockit.Injectable;
import mockit.Tested;
import mockit.Mocked;


public class DepositControllerTest {

Expand All @@ -24,21 +25,23 @@ public class DepositControllerTest {
@Injectable
JavaMailSender sender;

@Capturing
KafkaConsumerFactory capturingKafkaConsumerFactory;
@Mocked
KafkaConsumerFactory mockedCapturingKafkaConsumerFactory;

@Capturing
KafkaConsumerRestDepositor capturingKafkaConsumerRestDepositor;
@Mocked
KafkaConsumerRestDepositor mockedCapturingKafkaConsumerRestDepositor;

@Capturing
URI capturingURI;
@Mocked
URI mockedCapturingURI;

// currently not running, seems to be in endless loop somewhere
// @Test
@Test
public void shouldRun() throws URISyntaxException {

new Expectations() {
{
capturingKafkaConsumerRestDepositor.run((String[]) any);
injectableDepositorProperties.getDestinationUrl(); result = "127.0.0.1";

mockedCapturingKafkaConsumerRestDepositor.run((String[]) any);
times = 1;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ public class KafkaConsumerFactoryTest {
@Mocked
DepositorProperties mockedDepositorProperties;

// currently failing due to attempt to connect to Kafka broker on creation of consumer
// attempted to mock kafka consumer constructor without luck
// @Test
// public void createConsumerShouldCreateConsumer() {
// new Expectations() {
// {
// // These are required because Properties throws NPE when values are null
// mockedDepositorProperties.getKafkaBrokers();
// result = "kafkaBrokers";

// mockedDepositorProperties.getGroupId();
// result = "groupId";

// }
// };
// assertNotNull(KafkaConsumerFactory.createConsumer(mockedDepositorProperties));
// }

@Test
public void createConsumerShouldCreateConsumer() {

new Expectations() {
{
// These are required because Properties throws NPE when values are null
mockedDepositorProperties.getKafkaBrokers();
result = "kafkaBrokers";

mockedDepositorProperties.getGroupId();
result = "groupId";

}
};
assertNotNull(KafkaConsumerFactory.createConsumer(mockedDepositorProperties));
}

@Test
public void testConstructorIsPrivate()
Expand Down

0 comments on commit 8dfca7f

Please sign in to comment.