Skip to content

Commit

Permalink
[#303] remove if statement to check if neo version log needed
Browse files Browse the repository at this point in the history
  • Loading branch information
oomelianchuk committed Nov 26, 2024
1 parent 41851bc commit fbbd847
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions src/main/java/com/xceptance/neodymium/util/AllureAddons.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

import com.codeborne.selenide.Selenide;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.codeborne.selenide.Selenide;
import com.google.common.collect.ImmutableMap;

import io.qameta.allure.Allure;
Expand Down Expand Up @@ -333,21 +333,17 @@ public static File getAllureResultsFolder()
public static void addLinkToReport(String message, String url)
{
}


public static void initializeEnvironmentInformation()
{
Map<String, String> environmentDataMap = new HashMap<String, String>();

if (!neoVersionLogged && Neodymium.configuration().logNeoVersion())
{
if (!AllureAddons.envFileExists())
{
LOGGER.info("This test uses Neodymium Library (version: " + Neodymium.getNeodymiumVersion()
+ "), MIT License, more details on https://github.com/Xceptance/neodymium-library");
neoVersionLogged = true;
environmentDataMap.putIfAbsent("Testing Framework", "Neodymium " + Neodymium.getNeodymiumVersion());
}
LOGGER.info("This test uses Neodymium Library (version: " + Neodymium.getNeodymiumVersion()
+ "), MIT License, more details on https://github.com/Xceptance/neodymium-library");
neoVersionLogged = true;
environmentDataMap.putIfAbsent("Testing Framework", "Neodymium " + Neodymium.getNeodymiumVersion());
}
if (!customDataAdded && Neodymium.configuration().enableCustomEnvironmentData())
{
Expand Down Expand Up @@ -384,27 +380,28 @@ public static void initializeEnvironmentInformation()
}
}


/**
*
* @param name
* of the attachment
* @param data
* that needs to be added as an attachment
*/
public static void addDataAsJsonToReport(String name, Object data)
public static void addDataAsJsonToReport(String name, Object data)
{
ObjectMapper mapper = new ObjectMapper();
String dataObjectJson;

try {

try
{
// covert Java object to JSON strings
dataObjectJson = mapper.setSerializationInclusion(Include.NON_NULL).writeValueAsString(data);

} catch (JsonProcessingException e) {

}
catch (JsonProcessingException e)
{
throw new RuntimeException(e);
}

Allure.addAttachment(name, "text/html", DataUtils.convertJsonToHtml(dataObjectJson), "html");
}
}

0 comments on commit fbbd847

Please sign in to comment.