Skip to content
Draft
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
133 changes: 69 additions & 64 deletions src/main/java/io/github/mapepire_ibmi/types/ServerTraceLevel.java
Original file line number Diff line number Diff line change
@@ -1,64 +1,69 @@
package io.github.mapepire_ibmi.types;

/**
* Enum representing the possible server trace levels.
*/
public enum ServerTraceLevel {
/**
* Tracing is turned off.
*/
OFF("OFF"),

/**
* All trace data is collected except datastream.
*/
ON("ON"),

/**
* Only error trace data is collected.
*/
ERRORS("ERRORS"),

/**
* All trace data is collected including datastream.
*/
DATASTREAM("DATASTREAM");

/**
* The server trace level.
*/
private String value;

/**
* Construct a new ServerTraceLevel instance.
*
* @param value The server trace level.
*/
ServerTraceLevel(String value) {
this.value = value;
}

/**
* Get the server trace level.
*
* @return The server trace level.
*/
public String getValue() {
return value;
}

/**
* Get the enum server trace level representation of a string.
*
* @param value The string representation of the server trace level.
* @return The enum representation of the server trace level.
*/
public static ServerTraceLevel fromValue(String value) {
for (ServerTraceLevel type : values()) {
if (type.value.equals(value)) {
return type;
}
}
throw new IllegalArgumentException("Unknown value: " + value);
}
}
package io.github.mapepire_ibmi.types;

/**
* Enum representing the possible server trace levels.
*/
public enum ServerTraceLevel {
/**
* Tracing is turned off.
*/
OFF("OFF"),

/**
* All trace data is collected except datastream.
*/
ON("ON"),

/**
* Only error trace data is collected.
*/
ERRORS("ERRORS"),

/**
* All trace data is collected including datastream.
*/
DATASTREAM("DATASTREAM"),

/**
* Input data stream and errors.
*/
INPUT_AND_ERRORS("INPUT_AND_ERRORS");

/**
* The server trace level.
*/
private String value;

/**
* Construct a new ServerTraceLevel instance.
*
* @param value The server trace level.
*/
ServerTraceLevel(String value) {
this.value = value;
}

/**
* Get the server trace level.
*
* @return The server trace level.
*/
public String getValue() {
return value;
}

/**
* Get the enum server trace level representation of a string.
*
* @param value The string representation of the server trace level.
* @return The enum representation of the server trace level.
*/
public static ServerTraceLevel fromValue(String value) {
for (ServerTraceLevel type : values()) {
if (type.value.equals(value)) {
return type;
}
}
throw new IllegalArgumentException("Unknown value: " + value);
}
}
9 changes: 7 additions & 2 deletions src/test/java/io/github/mapepire_ibmi/TraceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,20 @@ void serverTracingOn() throws Exception {
}

@Test
void errorServerTracing() throws Exception {
void serverTracingErrors() throws Exception {
assertTraceData(invalidQuery, ServerTraceLevel.ERRORS, true);
}

@Test
void dataStreamServerTracing() throws Exception {
void serverTracingDatastream() throws Exception {
assertTraceData(invalidQuery, ServerTraceLevel.DATASTREAM, true);
}

@Test
void serverTracingInputAndErrors() throws Exception {
assertTraceData(invalidQuery, ServerTraceLevel.INPUT_AND_ERRORS, true);
}

GetTraceDataResult assertTraceData(String sql, ServerTraceLevel level, boolean traceExists) throws Exception {
SqlJob job = new SqlJob();
job.connect(MapepireTest.getCreds()).get();
Expand Down
Loading