Skip to content

Commit

Permalink
Updated Uri Validator in Test Agents, and added higher coverage and c…
Browse files Browse the repository at this point in the history
…leaner Gherkin Uri Validator tests (eclipse-uprotocol#46)

* corrected URI validator to validate given UUri dict, added validator gherkin tests, and created helper function to help cast data (Caster)

* removed .sh testrunner and removed some comments/prints

* hand-updated copyright headers

* added variable transport type into testrunner2lang.bat

* removed commented code and test.py sandbox

* updated step implementations and gherkin tests to have empty strings as input

* testrunner.bat has lang2 option, removed test.py, added spacing

* fixed constant command access in java test agent

* removed up-python repo folder

* formatted all implementation files

* removed prints

* added EOF new line format

* fixed a constants access variable
  • Loading branch information
hostilechild007 committed May 30, 2024
1 parent 517e672 commit c6ba0e3
Show file tree
Hide file tree
Showing 15 changed files with 964 additions and 392 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tck-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ jobs:
# Run behave command
echo "Running Test: $filename"
behave --define uE1=python --define transport=socket --format json --outfile "./reports/${filename}_python.json" --format html --outfile "./reports/${filename}_python.html" "$full_path"
behave --define uE1=java --define transport=socket --format json --outfile "./reports/${filename}_java.json" --format html --outfile "./reports/${filename}_java.html" "$full_path"
behave --define uE1=python --define uE2=java --define transport=socket --format json --outfile "./reports/${filename}_python.json" --format html --outfile "./reports/${filename}_python.html" "$full_path"
behave --define uE1=java --define uE2=python --define transport=socket --format json --outfile "./reports/${filename}_java.json" --format html --outfile "./reports/${filename}_java.html" "$full_path"
echo "Finished Test: $filename"
done
- name: Get Behave Scripts
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Distribution / packaging
.Python
__pycache__/
scripts/up-python/**
downloads/
testing/
lib/
Expand Down
125 changes: 56 additions & 69 deletions test_agent/java/src/main/java/org/eclipse/uprotocol/Caster.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,91 +25,78 @@
package org.eclipse.uprotocol;

public final class Caster {

private Caster() {
}

public static int toInt(Object value) {
int integer = 0;
if (value instanceof Double) {
double d = (double) value;
integer = (int) d;
}
else if (value instanceof Float) {
float f = (float) value;
integer = (int) f;
}
else if (value instanceof Integer) {
integer = (int) value;
}
else {
integer = Integer.parseInt(value.toString());
}
return integer;
if (value instanceof Double) {
double d = (double) value;
integer = (int) d;
} else if (value instanceof Float) {
float f = (float) value;
integer = (int) f;
} else if (value instanceof Integer) {
integer = (int) value;
} else {
integer = Integer.parseInt(value.toString());
}
return integer;
}

public static long toLong(Object value) {
long longVal = 0;
if (value instanceof Double) {
double d = (double) value;
longVal = (long) d;
}
else if (value instanceof Float) {
float f = (float) value;
longVal = (long) f;
}
else if (value instanceof Integer) {
longVal = (long) value;
}
else if (value instanceof Long) {
longVal = (long) value;
}
else {
try {
longVal = Long.parseLong(value.toString());
} catch (NumberFormatException ex) {
longVal = Long.parseUnsignedLong(value.toString());
}
}
return longVal;
if (value instanceof Double) {
double d = (double) value;
longVal = (long) d;
} else if (value instanceof Float) {
float f = (float) value;
longVal = (long) f;
} else if (value instanceof Integer) {
longVal = (long) value;
} else if (value instanceof Long) {
longVal = (long) value;
} else {
try {
longVal = Long.parseLong(value.toString());
} catch (NumberFormatException ex) {
longVal = Long.parseUnsignedLong(value.toString());
}
}
return longVal;
}

public static float toFloat(Object value) {
float f = 0;
if (value instanceof Double) {
double d = (double) value;
f = (float) d;
}
else if (value instanceof Float) {
f = (float) value;
}
else if (value instanceof Integer) {
int i = (int) value;
f = (float) i;
}
else {
f = Float.parseFloat(value.toString());
}
double d = (double) value;
f = (float) d;
} else if (value instanceof Float) {
f = (float) value;
} else if (value instanceof Integer) {
int i = (int) value;
f = (float) i;
} else {
f = Float.parseFloat(value.toString());
}
return f;
}

public static double toDouble(Object value) {
double d = 0;
if (value instanceof Double) {
d = (double) value;
}
else if (value instanceof Float) {
float f = (float) value;
d = (double) f;
}
else if (value instanceof Integer) {
int i = (int) value;
d = (double) i;
}
else {
d = Double.parseDouble(value.toString());
}
d = (double) value;
} else if (value instanceof Float) {
float f = (float) value;
d = (double) f;
} else if (value instanceof Integer) {
int i = (int) value;
d = (double) i;
} else {
d = Double.parseDouble(value.toString());
}
return d;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@ public class Constant {
public static final int BYTES_MSG_LENGTH = 32767;

}

Loading

0 comments on commit c6ba0e3

Please sign in to comment.