-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix broker logger causing db errors (#102)
- Loading branch information
1 parent
0956153
commit 043f615
Showing
3 changed files
with
91 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
.../src/test/java/de/sovity/edc/ext/brokerserver/services/logging/BrokerEventLoggerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (c) 2023 sovity GmbH | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* sovity GmbH - initial API and implementation | ||
* | ||
*/ | ||
|
||
package de.sovity.edc.ext.brokerserver.services.logging; | ||
|
||
import de.sovity.edc.ext.brokerserver.BrokerServerExtension; | ||
import de.sovity.edc.ext.brokerserver.db.TestDatabase; | ||
import de.sovity.edc.ext.brokerserver.db.TestDatabaseFactory; | ||
import de.sovity.edc.ext.brokerserver.db.jooq.enums.ConnectorOnlineStatus; | ||
import org.eclipse.edc.junit.annotations.ApiTest; | ||
import org.eclipse.edc.junit.extensions.EdcExtension; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import java.util.Map; | ||
|
||
import static de.sovity.edc.ext.brokerserver.TestUtils.createConfiguration; | ||
|
||
@ApiTest | ||
@ExtendWith(EdcExtension.class) | ||
public class BrokerEventLoggerTest { | ||
|
||
@RegisterExtension | ||
private static final TestDatabase TEST_DATABASE = TestDatabaseFactory.getTestDatabase(); | ||
|
||
@BeforeEach | ||
void setUp(EdcExtension extension) { | ||
extension.setConfiguration(createConfiguration(TEST_DATABASE, Map.of( | ||
BrokerServerExtension.KNOWN_CONNECTORS, "https://example.com/ids/data", | ||
BrokerServerExtension.NUM_THREADS, "0" | ||
))); | ||
} | ||
|
||
@Test | ||
void testDataOfferWriter_allSortsOfUpdates() { | ||
TEST_DATABASE.testTransaction(dsl -> { | ||
var brokerEventLogger = new BrokerEventLogger(); | ||
|
||
// Test that insertions insert required fields and don't cause DB errors | ||
brokerEventLogger.logConnectorUpdateSuccess(dsl, "https://example.com/ids/data", new ConnectorChangeTracker()); | ||
brokerEventLogger.logConnectorUpdateFailure(dsl, "https://example.com/ids/data", new BrokerEventErrorMessage("Message", "Stacktrace")); | ||
brokerEventLogger.logConnectorUpdateStatusChange(dsl, "https://example.com/ids/data", ConnectorOnlineStatus.ONLINE); | ||
brokerEventLogger.logConnectorUpdateStatusChange(dsl, "https://example.com/ids/data", ConnectorOnlineStatus.OFFLINE); | ||
}); | ||
} | ||
} |