Skip to content
Snippets Groups Projects
Commit fbdc861e authored by Andrea Burattin's avatar Andrea Burattin
Browse files

Improved code quality

parent 587489ed
No related branches found
No related tags found
No related merge requests found
......@@ -69,7 +69,7 @@ public abstract class StreamMiningAlgorithm<T extends Response> extends RichFlat
* The internal processor in charge of updating the internal status of the
* map.
*/
protected T process(BEvent event) throws Exception {
protected T process(BEvent event) {
try {
long value = 1;
if (processedEvents.value() != null) {
......
......@@ -159,12 +159,16 @@ public class XesLogSource extends BeamlineAbstractSource {
Path p = null;
if (SystemUtils.IS_OS_UNIX) {
FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwx------"));
p = Files.createTempFile("log", ".xes.gz", attr); // Compliant
p = Files.createTempFile("log", ".xes.gz", attr);
} else {
File f = Files.createTempFile("log", ".xes.gz").toFile(); // Compliant
f.setReadable(true, true);
f.setWritable(true, true);
File f = Files.createTempFile("log", ".xes.gz").toFile();
boolean configured =
f.setReadable(true, true) &&
f.setWritable(true, true) &&
f.setExecutable(true, true);
if (!configured) {
// potential issue with unable to configure all flags
}
p = f.toPath();
}
return p;
......
......@@ -2,6 +2,7 @@ package beamline.tests;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
......@@ -29,20 +30,26 @@ public class ResponsesTest {
@Test
public void directly_follow_tests() throws EventException {
assertThrows(IllegalArgumentException.class, () ->
new DirectlyFollowsRelation(
BEvent.create("p", "a", "c1"),
BEvent.create("p", "a", "c2")));
BEvent e1 = BEvent.create("p", "a", "c1");
BEvent e2 = BEvent.create("p", "a", "c2");
DirectlyFollowsRelation df = new DirectlyFollowsRelation(BEvent.create("p", "a", "c1"), BEvent.create("p", "b", "c1"));
DirectlyFollowsRelation df2 = new DirectlyFollowsRelation(BEvent.create("p", "a", "c2"), BEvent.create("p", "b", "c2"));
DirectlyFollowsRelation df3 = new DirectlyFollowsRelation(BEvent.create("p", "a", "c1"), BEvent.create("p", "d", "c1"));
assertThrows(IllegalArgumentException.class, () -> new DirectlyFollowsRelation(e1, e2));
assertTrue(df.equals(df2));
assertFalse(df.equals(df3));
assertFalse(df.equals(null));
assertFalse(df.equals(""));
assertTrue(df.equals(df));
BEvent e21 = BEvent.create("p", "a", "c1");
BEvent e22 = BEvent.create("p", "b", "c1");
BEvent e23 = BEvent.create("p", "a", "c2");
BEvent e24 = BEvent.create("p", "b", "c2");
BEvent e25 = BEvent.create("p", "d", "c1");
DirectlyFollowsRelation df = new DirectlyFollowsRelation(e21, e22);
DirectlyFollowsRelation df2 = new DirectlyFollowsRelation(e23, e24);
DirectlyFollowsRelation df3 = new DirectlyFollowsRelation(e21, e25);
assertEquals(df, df2);
assertNotEquals(df, df3);
assertNotEquals(null, df);
assertNotEquals("-", df);
assertEquals(df, df);
assertTrue(df.hashCode() == df2.hashCode());
assertFalse(df.hashCode() == df3.hashCode());
......@@ -56,8 +63,8 @@ public class ResponsesTest {
StringResponse sr = new StringResponse("");
sr.set(unique);
assertTrue(sr.get().equals(unique));
assertTrue(sr.toString().equals(unique));
assertEquals(sr.get(), unique);
assertEquals(sr.toString(), unique);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment