Skip to content

Commit

Permalink
Merge pull request #8 from CDOT-CV/fix/sdw-failing-tests
Browse files Browse the repository at this point in the history
Fix failing unit tests
  • Loading branch information
payneBrandon authored Aug 25, 2023
2 parents 410e977 + ebeedcf commit a169a44
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
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,20 +25,22 @@ public class DepositControllerTest {
@Injectable
JavaMailSender sender;

@Capturing
@Mocked
KafkaConsumerFactory capturingKafkaConsumerFactory;

@Capturing
@Mocked
KafkaConsumerRestDepositor capturingKafkaConsumerRestDepositor;

@Capturing
@Mocked
URI capturingURI;

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

new Expectations() {
{
injectableDepositorProperties.getDestinationUrl(); result = "127.0.0.1";

capturingKafkaConsumerRestDepositor.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 a169a44

Please sign in to comment.