Search in sources :

Example 6 with Link

use of com.opentext.ia.sdk.support.http.rest.Link in project infoarchive-sip-sdk by Enterprise-Content-Management.

the class WhenConfiguringServerUsingYaml method shouldDeferToServerWhenItSupportsYamlConfiguration.

@Test
void shouldDeferToServerWhenItSupportsYamlConfiguration() throws IOException {
    String configurationUri = randomUri();
    Services services = new Services();
    services.getLinks().put(LINK_CONFIGURATION, new Link(configurationUri));
    when(httpClient.get(any(), any(), eq(Services.class))).thenReturn(services);
    configurer.configure(connection);
    verify(httpClient).put(eq(configurationUri), any(), eq(String.class), anyString());
    verify(clientSideConfigurer, never()).configure(any());
}
Also used : Services(com.opentext.ia.sdk.dto.Services) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Link(com.opentext.ia.sdk.support.http.rest.Link) Test(org.junit.jupiter.api.Test)

Example 7 with Link

use of com.opentext.ia.sdk.support.http.rest.Link in project infoarchive-sip-sdk by Enterprise-Content-Management.

the class WhenUsingInfoArchive method shouldIngestWithIngestDirect.

@Test
void shouldIngestWithIngestDirect() throws IOException {
    Link link = new Link();
    link.setHref(BILLBOARD_URI);
    links.put(InfoArchiveLinkRelations.LINK_INGEST_DIRECT, link);
    configureServer();
    InputStream sip = IOUtils.toInputStream(SOURCE, StandardCharsets.UTF_8);
    IngestionResponse ingestionResponse = mock(IngestionResponse.class);
    when(restClient.post(anyString(), eq(IngestionResponse.class), any(Part.class), any(Part.class))).thenReturn(ingestionResponse);
    String aipId = "sip002";
    when(ingestionResponse.getAipId()).thenReturn(aipId);
    assertEquals(aipId, archiveClient.ingestDirect(sip), "AIP ID");
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Part(com.opentext.ia.sdk.support.http.Part) StringContains.containsString(org.hamcrest.core.StringContains.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Link(com.opentext.ia.sdk.support.http.rest.Link) Test(org.junit.jupiter.api.Test)

Example 8 with Link

use of com.opentext.ia.sdk.support.http.rest.Link in project infoarchive-sip-sdk by Enterprise-Content-Management.

the class WhenUsingInfoArchive method getJobInstanceLog.

@Test
void getJobInstanceLog() throws IOException {
    JobInstance jobInstance = new JobInstance();
    Map<String, Link> link = new HashMap<>();
    link.put(InfoArchiveLinkRelations.LINK_LOG, new Link("uri-for-jobinstance-log"));
    jobInstance.setLinks(link);
    when(restClient.get("uri-for-jobinstance-log", String.class)).thenReturn("id: abc, \"logMessages\" : [ { sample data } ]");
    String logJson = JobsUtil.getLog(jobInstance, connection.getRestClient());
    assertThat(logJson, notNullValue());
    assertThat(logJson, containsString("\"logMessages\" : [ {"));
}
Also used : HashMap(java.util.HashMap) StringContains.containsString(org.hamcrest.core.StringContains.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Link(com.opentext.ia.sdk.support.http.rest.Link) Test(org.junit.jupiter.api.Test)

Example 9 with Link

use of com.opentext.ia.sdk.support.http.rest.Link in project infoarchive-sip-sdk by Enterprise-Content-Management.

the class WhenUsingInfoArchive method getBatchItemLog.

@Test
void getBatchItemLog() throws IOException {
    BatchItem firstBatchItem = new BatchItem();
    Map<String, Link> link = new HashMap<>();
    link.put(InfoArchiveLinkRelations.LINK_LOG, new Link("uri-for-batchitem-log"));
    firstBatchItem.setLinks(link);
    when(restClient.get("uri-for-batchitem-log", String.class)).thenReturn("id: abc, \"logMessages\" : [ { sample data } ]");
    String logJson = JobsUtil.getLog(firstBatchItem, connection.getRestClient());
    assertThat(logJson, notNullValue());
    assertThat(logJson, containsString("\"logMessages\" : [ {"));
}
Also used : HashMap(java.util.HashMap) StringContains.containsString(org.hamcrest.core.StringContains.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Link(com.opentext.ia.sdk.support.http.rest.Link) Test(org.junit.jupiter.api.Test)

Aggregations

Link (com.opentext.ia.sdk.support.http.rest.Link)9 Test (org.junit.jupiter.api.Test)7 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 StringContains.containsString (org.hamcrest.core.StringContains.containsString)6 HashMap (java.util.HashMap)4 SearchQuery (com.opentext.ia.sdk.dto.query.SearchQuery)3 Comparison (com.opentext.ia.sdk.dto.query.Comparison)2 ContentResult (com.opentext.ia.sdk.client.api.ContentResult)1 QueryResult (com.opentext.ia.sdk.client.api.QueryResult)1 ContentResultFactory (com.opentext.ia.sdk.client.impl.ContentResultFactory)1 DefaultContentResult (com.opentext.ia.sdk.client.impl.DefaultContentResult)1 BuildProperties (com.opentext.ia.sdk.dto.ProductInfo.BuildProperties)1 Services (com.opentext.ia.sdk.dto.Services)1 ExportConfiguration (com.opentext.ia.sdk.dto.export.ExportConfiguration)1 ExportConfigurations (com.opentext.ia.sdk.dto.export.ExportConfigurations)1 ExportPipeline (com.opentext.ia.sdk.dto.export.ExportPipeline)1 ExportPipelines (com.opentext.ia.sdk.dto.export.ExportPipelines)1 ExportTransformation (com.opentext.ia.sdk.dto.export.ExportTransformation)1 ExportTransformations (com.opentext.ia.sdk.dto.export.ExportTransformations)1 Item (com.opentext.ia.sdk.dto.query.Item)1