Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
soimugeo committed Dec 16, 2024
1 parent 7cfb90f commit 65b7dc9
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class MongoConfiguration extends AbstractMongoClientConfiguration {
@Value("${spring.data.mongodb.database}")
private String databaseName;

@Value("${spring.data.mongodb.uri:mongodb://localhost:27017}")
@Value("${spring.data.mongodb.uri}")
private String mongoUri;

@Nonnull
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ spring:
password: guest
data.mongodb:
host: mongo
port: 27017
database: webprotege
auto-index-creation: true
uri: mongodb://${spring.data.mongodb.host}:${spring.data.mongodb.port}/${spring.data.mongodb.database}

webprotege:
rabbitmq:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.test.context.ActiveProfiles;
import uk.ac.manchester.cs.owl.owlapi.OWLClassImpl;

import java.util.ArrayList;
Expand All @@ -28,7 +29,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;


@ActiveProfiles("test")
public class HighLevelBusinessEventsIntegrationTest extends IntegrationTest {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ public static void closeContainers(){
private static void setUpMongo(){
var imageName = DockerImageName.parse("mongo");
mongoDBContainer = new MongoDBContainer(imageName)
.withExposedPorts(27017, 27017);
.withExposedPorts(27017);
mongoDBContainer.start();

var mappedHttpPort = mongoDBContainer.getMappedPort(27017);
LOGGER.info("MongoDB port 27017 is mapped to {}", mappedHttpPort);
System.setProperty("spring.data.mongodb.port", Integer.toString(mappedHttpPort));
var mappedPort = mongoDBContainer.getMappedPort(27017);
var mongoUri = String.format("mongodb://localhost:%d", mappedPort);

System.setProperty("spring.data.mongodb.uri", mongoUri);
System.setProperty("spring.data.mongodb.port", Integer.toString(mappedPort));
}

private static void setUpRabbitMq(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.springframework.context.annotation.Import;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import reactor.core.publisher.Mono;

Expand All @@ -23,6 +24,7 @@
@ExtendWith({SpringExtension.class, RabbitTestExtension.class, MongoTestExtension.class})
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
@Import({WebprotegeEventsHistoryApplication.class})
@ActiveProfiles("test")
public class GetChangedEntitiesCommandHandlerIT {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.springframework.context.annotation.Import;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import reactor.core.publisher.Mono;

Expand All @@ -28,6 +29,7 @@
@ExtendWith({SpringExtension.class, RabbitTestExtension.class, MongoTestExtension.class})
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
@Import({WebprotegeEventsHistoryApplication.class})
@ActiveProfiles("test")
public class GetProjectChangesForHistoryViewCommandHandlerIntegrationTest {

@Autowired
Expand Down
14 changes: 11 additions & 3 deletions src/test/resources/application-test.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
spring:
application:
name: webprotege-linearization-service
name: EventsHistory
rabbitmq:
host: rabbitmq
host: localhost
port: 5672
password: guest
username: guest
Expand All @@ -12,4 +12,12 @@ spring:
port: 27017
database: webprotege
auto-index-creation: true
uri: mongodb://${spring.data.mongodb.host}:${spring.data.mongodb.port}/webprotege
uri: mongodb://${spring.data.mongodb.host}:${spring.data.mongodb.port}/webprotege

webprotege:
rabbitmq:
requestqueue: webprotege-events-history-queue
responsequeue: webprotege-events-history-response
eventsqueue: webprotege-events-history-event-queue
timeout: 60000
event-subscribe: true
4 changes: 0 additions & 4 deletions src/test/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ spring:
port: 5672
username: guest
password: guest
data.mongodb:
host: mongo
database: webprotege
auto-index-creation: true

webprotege:
rabbitmq:
Expand Down

0 comments on commit 65b7dc9

Please sign in to comment.