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
58 changes: 10 additions & 48 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.ecsp</groupId>
<version>1.0.0</version>
<version>1.0.1</version>
<artifactId>ro</artifactId>
<name>ro</name>
<description>RO library for ECSP project</description>
Expand Down Expand Up @@ -124,25 +124,14 @@
**/org/eclipse/ecsp/platform/services/ro/constant/*.java,
**/org/eclipse/ecsp/platform/services/ro/service/*.java,
**/org/eclipse/ecsp/platform/services/ro/configure/*.java,
**/org/eclipse/ecsp/ro/utils/NotificationUtil.java,
**/org/eclipse/ecsp/ro/queue/AbstractQueueHandler.java,
**/org/eclipse/ecsp/ro/queue/RequestQueueHandler.java,
**/org/eclipse/ecsp/ro/RoScheduleV2DAOMongoImpl.java,
**/org/eclipse/ecsp/ro/utils/CacheUtil.java,
**/org/eclipse/ecsp/ro/utils/CachedKeyUtil.java,
**/org/eclipse/ecsp/ro/utils/OutboundUtil.java,
**/org/eclipse/ecsp/ro/queue/DeviceMessageFailureQueueHandler.java,
**/org/eclipse/ecsp/ro/utils/Utils.java,
**/org/eclipse/ecsp/ro/utils/TimeZoneUtils.java,
**/org/eclipse/ecsp/ro/RoDAOMongoImpl.java,
**/org/eclipse/ecsp/platform/services/ro/rest/RCPDController.java,
**/org/eclipse/ecsp/platform/services/ro/rest/ROHoodTrunkLiftgateController.java,
**/org/eclipse/ecsp/ro/notification/StockingRuleNotificationResolver.java,
**/org/eclipse/ecsp/platform/services/ro/rest/ROHornLightsAlarmController.java,
**/org/eclipse/ecsp/platform/services/ro/rest/ROStatusHistoryController.java,
**/org/eclipse/ecsp/ro/queue/ResponseQueueHandler.java,
**/org/eclipse/ecsp/platform/services/ro/handler/ApiRequestHandler.java,
**/org/eclipse/ecsp/ro/notification/identifier/NotificationArchAndECUTypeResolver.java
</sonar.exclusions>

<!-- Jacoco Plugin Properties -->
Expand Down Expand Up @@ -192,6 +181,7 @@
<checkstyle.config.location>${project.basedir}/checkstyle.xml</checkstyle.config.location>
<sonar.java.checkstyle.reportPaths>${project.build.directory}/checkstyle-result.xml
</sonar.java.checkstyle.reportPaths>
<central-publishing-maven-plugin.version>0.7.0</central-publishing-maven-plugin.version>
</properties>

<!-- ############ DEPENDENCIES ############ -->
Expand Down Expand Up @@ -632,16 +622,6 @@
</pluginRepository>
</pluginRepositories>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<!-- To download third party dependencies from non public repository -->
<profiles>
<profile>
Expand Down Expand Up @@ -671,27 +651,19 @@
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>${central-publishing-maven-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
<publishingServerId>central</publishingServerId>
<autoPublish>true</autoPublish>
<waitUntil>published</waitUntil>
<centralSnapshotsUrl>https://central.sonatype.com/repository/maven-snapshots/</centralSnapshotsUrl>
<skipPublishing>false</skipPublishing>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -741,16 +713,6 @@
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
Expand Down
4 changes: 3 additions & 1 deletion ro-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
<parent>
<groupId>org.eclipse.ecsp</groupId>
<artifactId>ro</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</parent>
<artifactId>ro-api</artifactId>
<name>ro-api</name>
<description>ro library for ECSP project</description>
<url>https://github.com/eclipse-ecsp/ro</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>org.eclipse.ecsp.platform.services.ro.Application</start-class>
Expand Down
4 changes: 3 additions & 1 deletion ro-entities/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
<parent>
<groupId>org.eclipse.ecsp</groupId>
<artifactId>ro</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</parent>
<artifactId>ro-entities</artifactId>
<name>ro-entities</name>
<description>ro library for ECSP project</description>
<url>https://github.com/eclipse-ecsp/ro</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Expand Down
4 changes: 3 additions & 1 deletion ro-sp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
<parent>
<groupId>org.eclipse.ecsp</groupId>
<artifactId>ro</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</parent>
<artifactId>ro-sp</artifactId>
<name>ro-sp</name>
<description>ro library for ECSP project</description>
<url>https://github.com/eclipse-ecsp/ro</url>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
44 changes: 44 additions & 0 deletions ro-sp/src/test/java/org/eclipse/ecsp/ro/RoDAOMongoImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
package org.eclipse.ecsp.ro;

import io.prometheus.client.CollectorRegistry;
import org.eclipse.ecsp.domain.ro.Ro;
import org.eclipse.ecsp.nosqldao.IgniteQuery;
import org.eclipse.ecsp.testutils.CommonTestBase;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
Expand All @@ -51,6 +53,7 @@
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.Optional;

/**
* Tests for {@link RoDAOMongoImpl}.
Expand Down Expand Up @@ -81,4 +84,45 @@ public void getLatesRIEntityForNotification() {
Assertions.assertNull(roDAOMongo.getLatesRIEntityForNotification("sessionId", "vehicleId"));
}

@Test
public void testGetRIEntityByFieldName_ReturnsEmpty() {
Optional<Ro> result = roDAOMongo.getRIEntityByFieldName("someRequestID", "someVehicleId");
Assertions.assertTrue(result.isEmpty());
}

@Test
public void testPrepareIgniteQueryForRoRequest() {
IgniteQuery query = roDAOMongo.prepareIgniteQueryForRoRequest("roReqId", "vehicleId");
Assertions.assertNotNull(query);
}

@Test
public void testPrepareIgniteQueryBySessionIdANDMsgId() {
IgniteQuery query = roDAOMongo.prepareIgniteQueryBySessionIdANDMsgId("vehicleId", "sessionId", "msgId");
Assertions.assertNotNull(query);
}

@Test
public void testPrepareIgniteQueryForRIRequestWithSessionId() {
IgniteQuery query = roDAOMongo.prepareIgniteQueryForRIRequestWithSessionId("sessionId", "vehicleid");
Assertions.assertNotNull(query);
}

@Test
public void testGetROEntityByFieldNameByRoReqIdExceptACV_ReturnsEmpty() {
Optional<Ro> result = roDAOMongo.getROEntityByFieldNameByRoReqIdExceptACV("vehicleId", "roRequestId");
Assertions.assertTrue(result.isEmpty());
}

@Test
public void testGetROEntityByFieldNameByRoReqId_ReturnsEmpty() {
Optional<Ro> result = roDAOMongo.getROEntityByFieldNameByRoReqId("vehicleId", "roRequestId");
Assertions.assertTrue(result.isEmpty());
}

@Test
public void testGetROEntityByFieldNameByBizIdExceptACV_ReturnsEmpty() {
Optional<Ro> result = roDAOMongo.getROEntityByFieldNameByBizIdExceptACV("vehicleId", "sessionId");
Assertions.assertTrue(result.isEmpty());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.eclipse.ecsp.ro.dma;

import org.eclipse.ecsp.entities.IgniteEvent;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.lang.reflect.Field;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;

class DefaultDMAShoulderTapResolverTest {

private DefaultDMAShoulderTapResolver resolver;

@BeforeEach
void setUp() {
resolver = new DefaultDMAShoulderTapResolver();
}

private void injectShoulderTapValue(boolean value) throws Exception {
Field field = DefaultDMAShoulderTapResolver.class.getDeclaredField("shoulderTap");
field.setAccessible(true);
field.set(resolver, value);
}

@Test
void testIsShoulderTap_WhenTrue() throws Exception {
injectShoulderTapValue(true);

IgniteEvent mockEvent = mock(IgniteEvent.class);
boolean result = resolver.isShoulderTap(mockEvent);

assertTrue(result, "Expected shoulderTap to be true");
}

@Test
void testIsShoulderTap_WhenFalse() throws Exception {
injectShoulderTapValue(false);

IgniteEvent mockEvent = mock(IgniteEvent.class);
boolean result = resolver.isShoulderTap(mockEvent);

assertFalse(result, "Expected shoulderTap to be false");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package org.eclipse.ecsp.ro.processor.strategy.impl.rcpd;

import org.apache.kafka.streams.processor.api.Record;
import org.eclipse.ecsp.analytics.stream.base.StreamProcessingContext;
import org.eclipse.ecsp.entities.IgniteEvent;
import org.eclipse.ecsp.entities.IgniteEventImpl;
import org.eclipse.ecsp.key.IgniteKey;
import org.eclipse.ecsp.ro.processor.RCPDHandler;
import org.eclipse.ecsp.services.utils.ServiceUtil;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.test.util.ReflectionTestUtils;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

/**
* RCPDRequestProcessorTest - This class contains unit tests for the RCPDRequestProcessor.
*/
@ExtendWith(MockitoExtension.class)
class RCPDRequestProcessorTest {

// Mock dependencies using @Mock
@Mock
private RCPDHandler rcpdEventHandler;

@Mock
private ServiceUtil serviceUtil;

@InjectMocks
private RCPDRequestProcessor rcpdRequestProcessor;

// Define a value for the rcpdMqttTopic, which would normally be injected by Spring
private static final String MOCK_MQTT_TOPIC = "mock/rcpd/topic";

/**
* Set up method executed before each test.
* Used to inject the mocked @Value property using ReflectionTestUtils.
*/
@BeforeEach
void setUp() {
// Use ReflectionTestUtils to set the private field 'rcpdMqttTopic'
// This simulates how @Value would inject the property in a real Spring context.
ReflectionTestUtils.setField(rcpdRequestProcessor, "rcpdMqttTopic", MOCK_MQTT_TOPIC);
}

/**
* Test case for the process method.
* Verifies that:
* 1. rcpdEventHandler.processRCPDRequest is called with correct arguments.
* 2. The returned IgniteEventImpl has the correct devMsgTopicSuffix set.
* 3. ctxt.forward is called with the correctly constructed Kafka Record.
*/
@Test
void testProcess() {
IgniteKey mockKey = mock(IgniteKey.class);
IgniteEvent mockValue = mock(IgniteEvent.class);
Record<IgniteKey<?>, IgniteEvent> kafkaRecordIn = new Record<>(mockKey, mockValue, System.currentTimeMillis());

StreamProcessingContext mockCtxt = mock(StreamProcessingContext.class);

IgniteEventImpl mockRcpdReqImpl = mock(IgniteEventImpl.class);

when(rcpdEventHandler.processRCPDRequest(
mockKey,
mockValue,
serviceUtil
)).thenReturn(mockRcpdReqImpl);

// Act
rcpdRequestProcessor.process(kafkaRecordIn, mockCtxt);

// Assert
verify(rcpdEventHandler).processRCPDRequest(mockKey, mockValue, serviceUtil);

verify(mockRcpdReqImpl).setDevMsgTopicSuffix(MOCK_MQTT_TOPIC);

ArgumentCaptor<Record<IgniteKey<?>, IgniteEvent>> recordCaptor = ArgumentCaptor.forClass(Record.class);
verify(mockCtxt).forward(recordCaptor.capture());

Record<IgniteKey<?>, IgniteEvent> forwardedRecord = recordCaptor.getValue();

// Assertions on the forwarded record
// Verify the key of the forwarded record is the same as the input key
assertEquals(mockKey, forwardedRecord.key());
// Verify the value of the forwarded record is the mockRcpdReqImpl (after topic suffix is set)
assertEquals(mockRcpdReqImpl, forwardedRecord.value());
}
}
Loading
Loading