Skip to content

Commit

Permalink
Update test case
Browse files Browse the repository at this point in the history
  • Loading branch information
utas-raymondng committed Oct 1, 2024
1 parent 50b3609 commit 0a0f79b
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import au.org.aodn.geonetwork4.Setup;
import au.org.aodn.geonetwork_api.openapi.api.helper.SiteHelper;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.fao.geonet.domain.Group;
import org.fao.geonet.domain.Metadata;
import org.fao.geonet.domain.MetadataHarvestInfo;
import org.fao.geonet.domain.MetadataSourceInfo;
Expand Down Expand Up @@ -64,13 +65,20 @@ public void verifyRecordExtraInfoWorks() {
params.host = "https://catalogue-imos.aodn.org.au/geonetwork";
harvester.setParams(params);

when(params.getOwnerIdGroup())
.thenReturn("100");

HarvestManagerImpl harvestManager = Mockito.mock(HarvestManagerImpl.class);
when(harvestManager.getHarvester(eq(harvesterUuid)))
.thenReturn(harvester);

Group group = new Group();
group.setLogo("logo.gif");

GroupRepository groupRepository = Mockito.mock(GroupRepository.class);
when(groupRepository.findById(anyInt()))
.thenReturn(Optional.empty());
.thenReturn(Optional.empty())
.thenReturn(Optional.of(group));

Api api = new Api(setup, metadataRepository, harvestManager, groupRepository, new ObjectMapper());

Expand All @@ -90,6 +98,9 @@ public void verifyRecordExtraInfoWorks() {
OaiPmhParams pmhParams = Mockito.mock(OaiPmhParams.class);
pmhParams.url = oaiHarvesterUrl;

when(pmhParams.getOwnerIdGroup())
.thenReturn("100");

when(oaiPmhHarvester.getParams())
.thenReturn(pmhParams);

Expand All @@ -102,10 +113,12 @@ public void verifyRecordExtraInfoWorks() {
v = api.getRecordExtraInfo(uuid);

// Only one link this time and suggestion is localhost
assertEquals("Logo have two suggestions", 1, ((List<String>)v.getBody().get(Api.SUGGEST_LOGOS)).size());
assertEquals("Logo have two suggestions", 2, ((List<String>)v.getBody().get(Api.SUGGEST_LOGOS)).size());
assertEquals("Logo link 1",
"http://localhost:8080/geonetwork/images/logos/dbee258b-8730-4072-96d4-2818a69a4afd.png",
((List<String>)v.getBody().get(Api.SUGGEST_LOGOS)).get(0));

assertEquals("Logo link 2",
"http://localhost:8080/geonetwork/images/harvesting/logo.gif",
((List<String>)v.getBody().get(Api.SUGGEST_LOGOS)).get(1));
}
}

0 comments on commit 0a0f79b

Please sign in to comment.