Skip to content

Commit

Permalink
Fix LinksApiTest integration test. Related to changes in geonetwork#7878
Browse files Browse the repository at this point in the history
 to process the links in a thread
  • Loading branch information
josegar74 authored and fxprunayre committed Mar 21, 2024
1 parent 25521da commit 035dbad
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions services/src/test/java/org/fao/geonet/api/links/LinksApiTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2001-2016 Food and Agriculture Organization of the
* Copyright (C) 2001-2024 Food and Agriculture Organization of the
* United Nations (FAO-UN), United Nations World Food Programme (WFP)
* and United Nations Environment Programme (UNEP)
*
Expand All @@ -24,8 +24,11 @@

import jeeves.server.context.ServiceContext;
import org.fao.geonet.domain.AbstractMetadata;
import org.fao.geonet.domain.Link;
import org.fao.geonet.kernel.url.UrlAnalyzer;
import org.fao.geonet.repository.LinkRepository;
import org.fao.geonet.services.AbstractServiceIntegrationTest;
import org.jdom.Element;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -36,6 +39,8 @@
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;

import java.util.List;

import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
Expand All @@ -51,6 +56,8 @@ public class LinksApiTest extends AbstractServiceIntegrationTest {
private WebApplicationContext wac;
@Autowired
private LinkRepository linkRepository;
@Autowired
private UrlAnalyzer urlAnalyzer;

private AbstractMetadata md;
private MockMvc mockMvc;
Expand All @@ -67,10 +74,6 @@ public void getLinks() throws Exception {
final MockHttpSession httpSession = this.loginAsAdmin();

this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
this.mockMvc.perform(post("/srv/api/records/links/analyze?uuid=" + md.getUuid())
.session(httpSession)
.accept(MediaType.parseMediaType("application/json")))
.andExpect(status().isCreated());

Assert.assertEquals(1, linkRepository.count());

Expand All @@ -96,5 +99,8 @@ public void getLinks() throws Exception {
private void createTestData() throws Exception {
loginAsAdmin(context);
this.md = injectMetadataInDb(getSampleMetadataXml(), context, true);
Element xmlData = this.md.getXmlData(false);

urlAnalyzer.processMetadata(xmlData, this.md);
}
}

0 comments on commit 035dbad

Please sign in to comment.