Skip to content

Commit

Permalink
Merge pull request #499 from psmf22/tool_debricked
Browse files Browse the repository at this point in the history
chore: fix versionhandling test
  • Loading branch information
psmf22 authored Jan 10, 2024
2 parents f795c76 + a3c98b3 commit 67aa785
Showing 1 changed file with 11 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,40 +1,28 @@
package com.fortify.cli.tool.versionHandling;

import java.io.InputStream;

import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fortify.cli.tool._common.helper.ToolDownloadDescriptor;
import com.fortify.cli.tool._common.helper.ToolHelper;

import org.junit.jupiter.api.Assertions;


public class VersionHandlingTest {
private static final ObjectMapper yamlObjectMapper = new ObjectMapper(new YAMLFactory());
String toolName = "fod-uploader";

@Test
public void testVersionHandling() throws Exception {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
String resourceFile = ToolHelper.getResourceFile(toolName, String.format("%s.yaml", toolName));
try (InputStream file = classLoader.getResourceAsStream(resourceFile)) {

var downloadDescriptor = yamlObjectMapper.readValue(file, ToolDownloadDescriptor.class);
var d = downloadDescriptor.getVersion("5");
//var d2 = downloadDescriptor.getVersion("20.");
var d3 = downloadDescriptor.getVersion("5.0");
var d4 = downloadDescriptor.getVersion("5.0.0");

Assertions.assertEquals(d.getVersion(), "5.4.0");
//Assertions.assertEquals(d2.getVersion(), "20.2.4");
Assertions.assertEquals(d3.getVersion(), "5.0.1");
Assertions.assertEquals(d4.getVersion(), "5.0.0");
} catch(Exception e) {
throw e;
}

var downloadDescriptor = ToolHelper.getToolDownloadDescriptor(toolName);;
var d = downloadDescriptor.getVersion("5");
//var d2 = downloadDescriptor.getVersion("20.");
var d3 = downloadDescriptor.getVersion("5.0");
var d4 = downloadDescriptor.getVersion("5.0.0");

Assertions.assertEquals(d.getVersion(), "5.4.0");
//Assertions.assertEquals(d2.getVersion(), "20.2.4");
Assertions.assertEquals(d3.getVersion(), "5.0.1");
Assertions.assertEquals(d4.getVersion(), "5.0.0");
}
}

0 comments on commit 67aa785

Please sign in to comment.