Skip to content
This repository was archived by the owner on Apr 4, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
* Indicates that a site was not found with regards to a specific query.
*/
public class SiteNotFoundException extends Exception {
public SiteNotFoundException(String msg) {
super(msg);
}

public SiteNotFoundException(String queryId, String siteId) {
super("Site with ID '" + siteId + "' was not found with regards to query with ID '" + queryId + "'.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ public List<String> getResultSiteIds(String queryId) throws QueryNotFoundExcepti

@Override
public String getSiteName(String siteId) throws SiteNotFoundException {
// TODO: implement (separate issue)
return null;
// TODO: replace this identity function with a real resolve routine later on.
if (siteId == null) {
throw new SiteNotFoundException("cannot find site name of site id with value 'null'");
}
return siteId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package de.numcodex.feasibility_gui_backend.query.broker.dsf;

import de.numcodex.feasibility_gui_backend.query.broker.SiteNotFoundException;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.mockito.InjectMocks;
import org.mockito.junit.jupiter.MockitoExtension;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

@ExtendWith(MockitoExtension.class)
public class DSFBrokerClientTest {

@InjectMocks
private DSFBrokerClient client;

@ParameterizedTest
@ValueSource(strings = {"my-site", "something", "identity", "Site 1"})
public void testGetSiteName_IsIdentity(String siteId) throws SiteNotFoundException {
assertEquals(siteId, client.getSiteName(siteId));
}

@Test
public void testGetSiteName_NullRaisesError() {
assertThrows(SiteNotFoundException.class, () -> client.getSiteName(null));
}
}