Skip to content

Commit

Permalink
adicionando o hash do método e o caminho do método
Browse files Browse the repository at this point in the history
  • Loading branch information
tassiovirginio committed Apr 4, 2024
1 parent 8b5a737 commit db7fcde
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/main/java/br/ufba/jnose/dto/TestSmell.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
package br.ufba.jnose.dto;

import java.io.Serializable;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;

public class TestSmell implements Serializable {
private static final long serialVersionUID = 1L;

private String name;
private String method;
private String range;
private TestClass testClass;
private String code;

public void setCode(String code){
this.code = code;
}

public String getCode(){
return code;
}

public String getRange() {
return range;
Expand All @@ -33,6 +46,45 @@ public void setMethod(String method) {
this.method = method;
}

public void setTestClass(TestClass testClass){
this.testClass = testClass;
}

public TestClass getTestClass(){
return this.testClass;
}

public String getMethodNameHash(){
String hash = "";
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(StandardCharsets.UTF_8.encode(this.method));
hash = String.format("%032x", new BigInteger(1, md5.digest()));
} catch (Exception e) {
e.printStackTrace();
}
return hash;
}

public String getMethodNameFullURIHash(){
if(this.testClass == null){
System.out.println("testClass = null ===========================");
}
String nomeProjeto = this.testClass.getProjectName();
String nomeClasse = this.testClass.getFullName();
String nomeMetodo = this.method;
String baseText = nomeProjeto + nomeClasse + nomeMetodo;
String hash = "";
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(StandardCharsets.UTF_8.encode(baseText));
hash = String.format("%032x", new BigInteger(1, md5.digest()));
} catch (Exception e) {
e.printStackTrace();
}
return hash;
}

@Override
public String toString() {
return "TestSmell{" +
Expand Down

0 comments on commit db7fcde

Please sign in to comment.