Skip to content

Commit

Permalink
Merge pull request #49 from Zir0-93/test_improvements
Browse files Browse the repository at this point in the history
Test improvements
  • Loading branch information
Zir0-93 authored Sep 3, 2016
2 parents b96ec73 + 206a9c8 commit 617294d
Show file tree
Hide file tree
Showing 25 changed files with 666 additions and 257 deletions.
7 changes: 7 additions & 0 deletions clarpse/.checkstyle
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
<fileset name="all" enabled="true" check-config-name="clarpse" local="false">
<file-match-pattern match-pattern="." include-pattern="true"/>
</fileset>
</fileset-config>
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package com.clarity.invocation;

import java.io.Serializable;
import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

public class AnnotationInvocation extends ComponentInvocation {
public class AnnotationInvocation extends ComponentInvocation implements Serializable {

private final List<Entry<String, HashMap<String, String>>> annotations = new ArrayList<Map.Entry<String, HashMap<String, String>>>();
private static final long serialVersionUID = 4146299386492074733L;
private final String type = "annotation";
private List<Entry<String, HashMap<String, String>>> annotations = new ArrayList<Map.Entry<String, HashMap<String, String>>>();

public List<Entry<String, HashMap<String, String>>> annotations() {
return annotations;
Expand All @@ -21,8 +24,23 @@ public AnnotationInvocation(final String invocationComponentName, final int line
annotations.add(annotation);
}

public AnnotationInvocation() {
super();
}

public AnnotationInvocation(String invokedComponent, List<Integer> lines,
List<Entry<String, HashMap<String, String>>> annotations2) {
super(invokedComponent, lines);
annotations = annotations2;
}

@Override
public boolean empty() {
return (super.empty() && annotations.isEmpty());
}

@Override
public Object clone() {
return new AnnotationInvocation(invokedComponent(), lines(), annotations);
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
package com.clarity.invocation;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.clarity.EmptyResource;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
import com.fasterxml.jackson.annotation.JsonTypeInfo;

/**
* Represents an invocation of another component in the code base.
*
* @author Muntazir Fadhel
*/
public abstract class ComponentInvocation implements EmptyResource {
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "type")
@JsonSubTypes({
@Type(value = AnnotationInvocation.class, name = "annotation"),
@Type(value = EmptyInvocation.class, name = "empty"),
@Type(value = MethodInvocation.class, name = "method"),
@Type(value = ThrownException.class, name = "exception"),
@Type(value = TypeDeclaration.class, name = "declaration"),
@Type(value = TypeExtension.class, name = "extension"),
@Type(value = TypeImplementation.class, name = "implementation"),
@Type(value = TypeParameter.class, name = "typeparameter") })
public abstract class ComponentInvocation implements EmptyResource, Serializable, Cloneable {

private final String invokedComponent;
private final ArrayList<Integer> invocationLines = new ArrayList<Integer>();
private static final long serialVersionUID = -242718695900611890L;
private String invokedComponent = "";
private List<Integer> invocationLines = new ArrayList<Integer>();

public ComponentInvocation(final String invocationComponentName, final int lineNum) {
invokedComponent = invocationComponentName;
Expand All @@ -26,17 +45,27 @@ public ComponentInvocation(final ComponentInvocation invocation) {
invokedComponent = invocation.invokedComponent();
}

public ComponentInvocation() {
}

public ComponentInvocation(String invokedComponent2, List<Integer> lines) {
invokedComponent = invokedComponent2;
invocationLines = lines;
}

public String invokedComponent() {
return invokedComponent;
}

public void insertLineNum(final int invocationLineNums) {
if (!invocationLines.contains(invocationLineNums)) {
invocationLines.add(invocationLineNums);
public void insertLineNums(final List<Integer> list) {
for (final Integer lineNum : list) {
if (!this.lines().contains(lineNum)) {
this.lines().add(lineNum);
}
}
}

public ArrayList<Integer> lines() {
public List<Integer> lines() {
return invocationLines;
}

Expand All @@ -45,4 +74,10 @@ public ArrayList<Integer> lines() {
boolean empty() {
return (invokedComponent.isEmpty() && invocationLines.isEmpty());
}

@Override
public Object clone() throws CloneNotSupportedException {

return super.clone();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package com.clarity.invocation;

public class EmptyInvocation extends ComponentInvocation {
import java.io.Serializable;
import java.util.List;

public class EmptyInvocation extends ComponentInvocation implements Serializable {

private static final long serialVersionUID = -3058881761749807208L;
public final String type = "empty";
public EmptyInvocation(String invocationComponentName, int lineNum) {
super(invocationComponentName, lineNum);
}
Expand All @@ -10,4 +15,17 @@ public EmptyInvocation(String invocationComponentName, int lineNum) {
public boolean empty() {
return true;
}

public EmptyInvocation() {
super();
}

public EmptyInvocation(String invokedComponent, List<Integer> lines) {
super(invokedComponent, lines);
}

@Override
public Object clone() {
return new EmptyInvocation(invokedComponent(), lines());
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
package com.clarity.invocation;

import java.io.Serializable;
import java.util.List;

public class MethodInvocation extends ComponentInvocation {

public class MethodInvocation extends ComponentInvocation implements Serializable {

private static final long serialVersionUID = 6518046913196400190L;
public final String type = "method";
public MethodInvocation(final String invocationComponentName, final int lineNum) {

super(invocationComponentName, lineNum);
}

public MethodInvocation() {
super();
}

public MethodInvocation(String invokedComponent, List<Integer> lines) {
super(invokedComponent, lines);
}

@Override
public Object clone() {
return new MethodInvocation(invokedComponent(), lines());
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
package com.clarity.invocation;

public class ThrownException extends ComponentInvocation {
import java.io.Serializable;
import java.util.List;

public class ThrownException extends ComponentInvocation implements Serializable {

private static final long serialVersionUID = 3346563314076095662L;
public final String type = "exception";
public ThrownException(String invocationComponentName, int lineNum) {
super(invocationComponentName, lineNum);
}

public ThrownException() {
super();
}

public ThrownException(String invokedComponent, List<Integer> lines) {
super(invokedComponent, lines);
}

@Override
public Object clone() {
return new ThrownException(invokedComponent(), lines());
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
package com.clarity.invocation;

public class TypeDeclaration extends ComponentInvocation {
import java.io.Serializable;
import java.util.List;

public class TypeDeclaration extends ComponentInvocation implements Serializable {

private static final long serialVersionUID = 7304258760520469246L;
public final String type = "declaration";
public TypeDeclaration(final String invocationComponentName, final int lineNum) {
super(invocationComponentName, lineNum);
}

public TypeDeclaration() {
super();
}

public TypeDeclaration(String invokedComponent, List<Integer> lines) {
super(invokedComponent, lines);
}

@Override
public Object clone() {
return new TypeDeclaration(invokedComponent(), lines());
}
}
20 changes: 19 additions & 1 deletion clarpse/src/main/java/com/clarity/invocation/TypeExtension.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
package com.clarity.invocation;

public final class TypeExtension extends ComponentInvocation {
import java.io.Serializable;
import java.util.List;

public final class TypeExtension extends ComponentInvocation implements Serializable {

private static final long serialVersionUID = 6641497827060470449L;
public final String type = "extension";
public TypeExtension(final String invocationComponentName, final int lineNum) {
super(invocationComponentName, lineNum);
}

public TypeExtension() {
super();
}

public TypeExtension(String invokedComponent, List<Integer> lines) {
super(invokedComponent, lines);
}

@Override
public Object clone() {
return new TypeExtension(invokedComponent(), lines());
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
package com.clarity.invocation;

public class TypeImplementation extends ComponentInvocation {
import java.io.Serializable;
import java.util.List;

public class TypeImplementation extends ComponentInvocation implements Serializable {

private static final long serialVersionUID = 7807962152246261233L;
public final String type = "implementation";

public TypeImplementation(String invocationComponentName, int lineNum) {
super(invocationComponentName, lineNum);
}

public TypeImplementation() {
super();
}

public TypeImplementation(String invokedComponent, List<Integer> lines) {
super(invokedComponent, lines);
}

@Override
public Object clone() {
return new TypeImplementation(invokedComponent(), lines());
}

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
package com.clarity.invocation;

public class TypeInstantiation extends ComponentInvocation {
import java.io.Serializable;
import java.util.List;

public class TypeInstantiation extends ComponentInvocation implements Serializable {

private static final long serialVersionUID = 7253490170234016131L;
public final String type = "instantiation";

public TypeInstantiation(String invocationComponentName, int lineNum) {
super(invocationComponentName, lineNum);
}

public TypeInstantiation() {
super();
}

public TypeInstantiation(String invokedComponent, List<Integer> lines) {
super(invokedComponent, lines);
}

@Override
public Object clone() {
return new TypeInstantiation(invokedComponent(), lines());
}

}
27 changes: 27 additions & 0 deletions clarpse/src/main/java/com/clarity/invocation/TypeParameter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.clarity.invocation;

import java.io.Serializable;
import java.util.List;

public class TypeParameter extends ComponentInvocation implements Serializable {

private static final long serialVersionUID = -6321838812633289752L;
public final String type = "typeparameter";

public TypeParameter(String invokedClass, int lineNumber) {
super(invokedClass, lineNumber);
}

public TypeParameter() {
super();
}

public TypeParameter(String invokedComponent, List<Integer> lines) {
super(invokedComponent, lines);
}

@Override
public Object clone() {
return new TypeParameter(invokedComponent(), lines());
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ private List<Component> getMethodComponentMatches(Component containingClassCmp,
// figure out the number of parameters for this method..
int methodParams = 0;
for (final String methodChildCmp : methodCmp.children()) {
if (srcModel.getComponent(methodChildCmp).componentType() == ComponentType.METHOD_PARAMETER_COMPONENT) {
final Component methodChildComponent = srcModel.getComponent(methodChildCmp);
if (methodChildComponent != null
&& methodChildComponent.componentType() == ComponentType.METHOD_PARAMETER_COMPONENT) {
methodParams++;
}
}
Expand Down
Loading

0 comments on commit 617294d

Please sign in to comment.