-
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.
Merge pull request #64 from DiSSCo/feature/add-source-system-name
Add source system name to digital specimen and digital media
- Loading branch information
Showing
21 changed files
with
171 additions
and
102 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
26 changes: 26 additions & 0 deletions
26
src/main/java/eu/dissco/core/translator/component/SourceSystemComponent.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,26 @@ | ||
package eu.dissco.core.translator.component; | ||
|
||
import eu.dissco.core.translator.properties.WebClientProperties; | ||
import eu.dissco.core.translator.repository.SourceSystemRepository; | ||
import lombok.Getter; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Getter | ||
@Component | ||
public class SourceSystemComponent { | ||
|
||
private final String sourceSystemID; | ||
private final String sourceSystemName; | ||
private final String sourceSystemEndpoint; | ||
|
||
public SourceSystemComponent(WebClientProperties webClientProperties, | ||
SourceSystemRepository repository) { | ||
this.sourceSystemID = webClientProperties.getSourceSystemId(); | ||
var sourceSystemInformation = repository.getSourceSystem(this.sourceSystemID); | ||
if (sourceSystemInformation == null) { | ||
throw new IllegalArgumentException("Source System Identifier: " + sourceSystemID + " not found"); | ||
} | ||
this.sourceSystemName = sourceSystemInformation.sourceSystemName(); | ||
this.sourceSystemEndpoint = sourceSystemInformation.sourceSystemUrl(); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/eu/dissco/core/translator/domain/SourceSystemInformation.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,5 @@ | ||
package eu.dissco.core.translator.domain; | ||
|
||
public record SourceSystemInformation(String sourceSystemName, String sourceSystemUrl) { | ||
|
||
} |
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
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
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
11 changes: 0 additions & 11 deletions
11
src/main/java/eu/dissco/core/translator/terms/SourceSystemId.java
This file was deleted.
Oops, something went wrong.
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
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
51 changes: 51 additions & 0 deletions
51
src/test/java/eu/dissco/core/translator/component/SourceSystemComponentTest.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,51 @@ | ||
package eu.dissco.core.translator.component; | ||
|
||
import static eu.dissco.core.translator.TestUtils.ENDPOINT; | ||
import static eu.dissco.core.translator.TestUtils.SOURCE_SYSTEM_ID; | ||
import static eu.dissco.core.translator.TestUtils.SOURCE_SYSTEM_NAME; | ||
import static eu.dissco.core.translator.TestUtils.givenSourceSystemInformation; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.mockito.BDDMockito.given; | ||
|
||
import eu.dissco.core.translator.properties.WebClientProperties; | ||
import eu.dissco.core.translator.repository.SourceSystemRepository; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class SourceSystemComponentTest { | ||
|
||
@Mock | ||
private WebClientProperties properties; | ||
@Mock | ||
private SourceSystemRepository repository; | ||
|
||
@Test | ||
void testGetSourceSystem() { | ||
// Given | ||
given(properties.getSourceSystemId()).willReturn(SOURCE_SYSTEM_ID); | ||
given(repository.getSourceSystem(SOURCE_SYSTEM_ID)).willReturn(givenSourceSystemInformation()); | ||
|
||
// When | ||
var component = new SourceSystemComponent(properties, repository); | ||
|
||
// Then | ||
assertThat(component.getSourceSystemName()).isEqualTo(SOURCE_SYSTEM_NAME); | ||
assertThat(component.getSourceSystemID()).isEqualTo(SOURCE_SYSTEM_ID); | ||
assertThat(component.getSourceSystemEndpoint()).isEqualTo(ENDPOINT); | ||
} | ||
|
||
@Test | ||
void testFailedGetSourceSystem() { | ||
// Given | ||
given(properties.getSourceSystemId()).willReturn(SOURCE_SYSTEM_ID); | ||
given(repository.getSourceSystem(SOURCE_SYSTEM_ID)).willReturn(null); | ||
|
||
// When / Then | ||
assertThrows(IllegalArgumentException.class, | ||
() -> new SourceSystemComponent(properties, repository)); | ||
} | ||
} |
Oops, something went wrong.