Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
java-version: '21'
distribution: 'adopt'
- name: Build with Maven
run: mvn --batch-mode --update-snapshots verify
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ The preferred flow is somewhat asynchronous and it is crucial to understand it,
>_Pay attention, that usually executing time consuming actions within the CI event call effectively means holding the main CI system execution thread, since most of the CI system's events are executing on the main thread.
Don't do that._


## Disclamer update
Certain versions of software accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company.
This software was acquired by Micro Focus on September 1, 2017, and is now offered by OpenText.
Expand Down
55 changes: 36 additions & 19 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,43 @@
install:
- ps: choco install temurin11 -y
- ps: |
Add-Type -AssemblyName System.IO.Compression.FileSystem
if (!(Test-Path -Path "C:\maven" )) {
(new-object System.Net.WebClient).DownloadFile(
'https://dlcdn.apache.org/maven/maven-3/3.9.11/binaries/apache-maven-3.9.11-bin.zip',
'C:\maven-bin.zip'
)
[System.IO.Compression.ZipFile]::ExtractToDirectory("C:\maven-bin.zip", "C:\maven")
}
- cmd: |
FOR /D %%F IN ("C:\Program Files\Eclipse Adoptium\jdk-11*") DO SET JAVA_HOME=%%F
SET PATH=C:\maven\apache-maven-3.9.11\bin;%JAVA_HOME%\bin;%PATH%
java -version
- ps: |
# Install JDK 21 only if it is not already installed
$jdk = Get-ChildItem "C:\Program Files\Eclipse Adoptium" -Directory -Filter "jdk-21*" -ErrorAction SilentlyContinue

if (-not $jdk) {
choco install temurin21 -y
}

- ps: |
Add-Type -AssemblyName System.IO.Compression.FileSystem

# Install Maven only if it is not already present
if (!(Test-Path "C:\maven\apache-maven-3.9.16\bin\mvn.cmd")) {
Remove-Item "C:\maven" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item "C:\maven-bin.zip" -Force -ErrorAction SilentlyContinue

(New-Object System.Net.WebClient).DownloadFile(
"https://dlcdn.apache.org/maven/maven-3/3.9.16/binaries/apache-maven-3.9.16-bin.zip",
"C:\maven-bin.zip"
)

[System.IO.Compression.ZipFile]::ExtractToDirectory(
"C:\maven-bin.zip",
"C:\maven"
)
}

- cmd: |
FOR /D %%F IN ("C:\Program Files\Eclipse Adoptium\jdk-21*") DO SET JAVA_HOME=%%F
SET PATH=C:\maven\apache-maven-3.9.16\bin;%JAVA_HOME%\bin;%PATH%
java -version
mvn -version

build_script:
- mvn compile spotbugs:check -T8
- mvn compile spotbugs:check -T8

test_script:
- mvn test -T8 -P jacoco-coverage

- mvn test -T8 -P jacoco-coverage

cache:
- C:\maven\
- C:\Users\appveyor\.m2
- C:\maven\
- C:\Users\appveyor\.m2
32 changes: 22 additions & 10 deletions integrations-dto/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@
<artifactId>integrations-dto</artifactId>

<properties>
<jackson.version>2.14.2</jackson.version>
<java.level>21</java.level>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<maven.compiler.release>21</maven.compiler.release>
<jackson.version>2.22.0</jackson.version>
<junit-jupiter.version>6.1.0</junit-jupiter.version>
</properties>

<dependencies>
Expand All @@ -61,13 +66,12 @@
<artifactId>jackson-dataformat-xml</artifactId>
<version>${jackson.version}</version>
</dependency>

<!-- TESTING -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>

</dependencies>

Expand All @@ -79,7 +83,14 @@
<groupId>org.apache.maven.plugins</groupId>
<configuration>
<sourcepath>${basedir}/src/main/java/com/hp/octane/integrations/dto</sourcepath>
<source>8</source>
<source>${java.level}</source>
</configuration>
</plugin>
<plugin>
<artifactId>spotbugs-maven-plugin</artifactId>
<groupId>com.github.spotbugs</groupId>
<configuration>
<excludeFilterFile>spotbugs-exclude.xml</excludeFilterFile>
</configuration>
</plugin>
</plugins>
Expand All @@ -94,12 +105,13 @@
<plugin>
<artifactId>maven-source-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<version>${maven-source-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<configuration>
<source>8</source>
<source>${java.level}</source>
</configuration>
</plugin>
</plugins>
Expand Down
15 changes: 15 additions & 0 deletions integrations-dto/spotbugs-exclude.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<!-- Exclude EI_EXPOSE_REP and EI_EXPOSE_REP2 for DTO classes -->
<!-- DTOs are designed to transfer data and exposing internal representation is acceptable -->
<Match>
<Bug pattern="EI_EXPOSE_REP,EI_EXPOSE_REP2" />
</Match>

<!-- Exclude CT_CONSTRUCTOR_THROW for provider base class -->
<Match>
<Class name="com.hp.octane.integrations.dto.DTOInternalProviderBase" />
<Bug pattern="CT_CONSTRUCTOR_THROW" />
</Match>
</FindBugsFilter>

Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public TestingToolType getTestingToolType() {
if (getUnits() == null || getUnits().isEmpty()) {
return TestingToolType.UNKNOWN;
}
return getUnits().get(0).getTestingToolType();
return getUnits().getFirst().getTestingToolType();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@
package com.hp.octane.integrations.dto;

import com.hp.octane.integrations.dto.general.CIServerTypes;
import org.junit.jupiter.api.Test;
import com.hp.octane.integrations.dto.general.CIPluginInfo;
import com.hp.octane.integrations.dto.general.CIServerInfo;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;

/**
* Basic tests to verify if every DTO is registered and available for serialization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@
package com.hp.octane.integrations.dto.connectivity;

import com.hp.octane.integrations.dto.DTOFactory;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;

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

/**
* OctaneTaskAbridged test
Expand All @@ -48,20 +49,23 @@
public class OctaneRequestTest {
private static final DTOFactory dtoFactory = DTOFactory.getInstance();

@Test(expected = IllegalArgumentException.class)
@Test
public void testA() {
dtoFactory.newDTO(OctaneRequest.class).setUrl(null);
}
assertThrows(IllegalArgumentException.class, () ->
dtoFactory.newDTO(OctaneRequest.class).setUrl(null));
}

@Test(expected = IllegalArgumentException.class)
@Test
public void testB() {
dtoFactory.newDTO(OctaneRequest.class).setUrl("");
}
assertThrows(IllegalArgumentException.class, () ->
dtoFactory.newDTO(OctaneRequest.class).setUrl(""));
}

@Test(expected = IllegalArgumentException.class)
@Test
public void testC() {
dtoFactory.newDTO(OctaneRequest.class).setUrl("some non valid url");
}
assertThrows(IllegalArgumentException.class, () ->
dtoFactory.newDTO(OctaneRequest.class).setUrl("some non valid url"));
}

@Test
public void testD() {
Expand All @@ -70,10 +74,11 @@ public void testD() {
assertEquals(validURL, request.getUrl());
}

@Test(expected = IllegalArgumentException.class)
@Test
public void testE() {
dtoFactory.newDTO(OctaneRequest.class).setMethod(null);
}
assertThrows(IllegalArgumentException.class, () ->
dtoFactory.newDTO(OctaneRequest.class).setMethod(null));
}

@Test
public void testF1() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
package com.hp.octane.integrations.dto.connectivity;

import com.hp.octane.integrations.dto.DTOFactory;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;

/**
* OctaneTaskAbridged test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import com.hp.octane.integrations.dto.executor.impl.TestingToolType;
import com.hp.octane.integrations.dto.scm.SCMRepository;
import com.hp.octane.integrations.dto.scm.SCMType;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -64,7 +64,7 @@ public void testDiscoveryInfo() {
.setScmRepository(scm);

String json = dtoFactory.dtoToJson(discInfo);
Assert.assertNotNull(json);
Assertions.assertNotNull(json);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import com.hp.octane.integrations.dto.entities.*;
import com.hp.octane.integrations.dto.pipelines.PipelineContext;
import com.hp.octane.integrations.dto.pipelines.PipelineContextList;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

/**
* Created by gullery on 03/01/2016.
Expand All @@ -55,8 +55,8 @@ public void testEntity() {

String json = dtoFactory.dtoToJson(entity);

Assert.assertNotNull(json);
Assert.assertTrue(json.length() > 8);
Assertions.assertNotNull(json);
Assertions.assertTrue(json.length() > 8);
}

@Test
Expand All @@ -75,12 +75,12 @@ public void testEntityList() {
list.addEntity(entity2);

String json = dtoFactory.dtoToJson(list);
Assert.assertNotNull(json);
Assert.assertTrue(json.length() > 10);
Assertions.assertNotNull(json);
Assertions.assertTrue(json.length() > 10);


EntityList serializedList = dtoFactory.dtoFromJson(json, EntityList.class);
Assert.assertEquals(2, serializedList.getData().size());
Assertions.assertEquals(2, serializedList.getData().size());
}

@Test
Expand All @@ -99,48 +99,48 @@ public void testResponseEntityList() {
list.setTotalCount(2);

String json = dtoFactory.dtoToJson(list);
Assert.assertNotNull(json);
Assert.assertTrue(json.length() > 10);
Assertions.assertNotNull(json);
Assertions.assertTrue(json.length() > 10);


EntityList serializedList = dtoFactory.dtoFromJson(json, ResponseEntityList.class);
Assert.assertEquals(2, serializedList.getData().size());
Assertions.assertEquals(2, serializedList.getData().size());
}


@Test
public void testParseResponseEntitiyList() {
String json = "{\"total_count\":1,\"data\":[{\"type\":\"defect\",\"workspace_id\":1002,\"logical_name\":\"439wn0yylz2j4bgp0r72kegzp\",\"name\":\"def1\",\"id\":\"3001\"}],\"exceeds_total_count\":false}";
ResponseEntityList serializedList = dtoFactory.dtoFromJson(json, ResponseEntityList.class);
Assert.assertEquals(1, serializedList.getData().size());
Assertions.assertEquals(1, serializedList.getData().size());
}

@Test
public void testParseOctaneException() {
String json = "{\"error_code\":\"platform.web_application\",\"correlation_id\":\"o5jp1yvjo54lxbjmo7dxz12v6\",\"description\":\"HTTP 404 Not Found\",\"description_translated\":\"HTTP 404 Not Found\",\"properties\":null,\"stack_trace\":\"java.ws.rs.NotFoundException: HTTP 404\",\"business_error\":false}\n";
OctaneRestExceptionData octaneRestExceptionData = dtoFactory.dtoFromJson(json, OctaneRestExceptionData.class);
Assert.assertEquals("platform.web_application", octaneRestExceptionData.getErrorCode());
Assertions.assertEquals("platform.web_application", octaneRestExceptionData.getErrorCode());
}
@Test
public void testParseOctaneBulkException() {
String json = "{\"total_count\":0,\"data\":[],\"exceeds_total_count\":false,\"errors\":[{\"error_code\":\"platform.unknown_field\",\"correlation_id\":\"o5jp1y5576mo0tdyd60g7n2v6\",\"description\":\"The entity type 'defect' does not have a field/s by name/s 'sss'\",\"description_translated\":\"The entity type 'defect' does not have a field/s by name/s 'sss'\",\"properties\":{\"entity_type\":\"defect\",\"field_name\":\"sss\"},\"stack_trace\":\"com.hp.mqm.bl.platform.exception.NonExistingFieldException\",\"business_error\":true}]}";
OctaneBulkExceptionData octaneException = dtoFactory.dtoFromJson(json, OctaneBulkExceptionData.class);
Assert.assertEquals("platform.unknown_field", octaneException.getErrors().get(0).getErrorCode());
Assertions.assertEquals("platform.unknown_field", octaneException.getErrors().getFirst().getErrorCode());
}


@Test
public void testParsePipelineContext() {
String json = "{\"contextEntityId\":2014,\"contextEntityName\":\"ss\",\"workspaceId\":1004,\"releaseId\":1013,\"ciJob\":{\"ciServer\":{\"id\":2002,\"workspaceId\":1004,\"instanceId\":\"d7cb541b-c22e-4ed5-a566-65854fb7aae1\",\"url\":\"http://localhost:9192/jenkins\",\"type\":\"jenkins\",\"name\":\"local\",\"sendingTime\":null},\"jobId\":2008,\"workspaceId\":1004,\"jobCiId\":\"ss\",\"name\":\"ss\",\"parameters\":[]},\"ignoreTests\":true,\"rootJobCiId\":\"ss\",\"taxonomies\":[{\"id\":1120,\"parent\":{\"id\":1087,\"name\":\"DB\"}}],\"listFields\":{\"test_tool_type\":[],\"test_level\":[{\"id\":1457}],\"test_type\":[],\"test_framework\":[]},\"contextEntityType\":\"pipeline\",\"pipelineRoot\":true}";
PipelineContext pc = dtoFactory.dtoFromJson(json, PipelineContext.class);
Assert.assertEquals(pc.getContextEntityId(),2014);
Assertions.assertEquals(pc.getContextEntityId(),2014);
}

@Test
public void testParsePipelineContextList() {
String json = "{\"data\":[{\"contextEntityId\":2014,\"contextEntityName\":\"ss\",\"workspaceId\":1004,\"releaseId\":null,\"ciJob\":{\"ciServer\":{\"id\":2002,\"workspaceId\":1004,\"instanceId\":\"d7cb541b-c22e-4ed5-a566-65854fb7aae1\",\"url\":\"http://localhost:9192/jenkins\",\"type\":\"jenkins\",\"name\":\"local\",\"sendingTime\":null},\"jobId\":2008,\"workspaceId\":1004,\"jobCiId\":\"ss\",\"name\":\"ss\",\"parameters\":[]},\"ignoreTests\":true,\"rootJobCiId\":\"ss\",\"taxonomies\":[{\"id\":1120,\"parent\":{\"id\":1087,\"name\":\"DB\"}}],\"listFields\":{\"test_tool_type\":[],\"test_level\":[{\"id\":1457}],\"test_type\":[],\"test_framework\":[]},\"contextEntityType\":\"pipeline\",\"pipelineRoot\":true},{\"contextEntityId\":1004,\"contextEntityName\":\"ss\",\"workspaceId\":1003,\"releaseId\":1005,\"ciJob\":{\"ciServer\":{\"id\":1002,\"workspaceId\":1003,\"instanceId\":\"d7cb541b-c22e-4ed5-a566-65854fb7aae1\",\"url\":\"http://localhost:9192/jenkins\",\"type\":\"jenkins\",\"name\":\"LOCAL JENKINS\",\"sendingTime\":null},\"jobId\":1003,\"workspaceId\":1003,\"jobCiId\":\"ss\",\"name\":\"ss\",\"parameters\":[]},\"ignoreTests\":false,\"rootJobCiId\":\"ss\",\"taxonomies\":[{\"id\":1075,\"parent\":{\"id\":1044,\"name\":\"Distribution\"}},{\"id\":1078,\"parent\":{\"id\":1046,\"name\":\"DB\"}}],\"listFields\":{\"test_tool_type\":[{\"id\":1280}],\"test_level\":[{\"id\":1266}],\"test_type\":[{\"id\":1271}],\"test_framework\":[{\"id\":1255}]},\"contextEntityType\":\"pipeline\",\"pipelineRoot\":true}]}";
PipelineContextList serializedList = dtoFactory.dtoFromJson(json, PipelineContextList.class);
Assert.assertEquals(2, serializedList.getData().size());
Assertions.assertEquals(2, serializedList.getData().size());
}

}
Loading