Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#417 #423

Merged
merged 3 commits into from
Mar 12, 2020
Merged

#417 #423

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
19 changes: 10 additions & 9 deletions src/test/java/org/jpeek/calculus/java/Lcom4Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@
import com.jcabi.xml.XML;
import java.io.IOException;
import java.util.HashMap;
import org.hamcrest.core.IsEqual;
import org.cactoos.scalar.ItemAt;
import org.jpeek.FakeBase;
import org.jpeek.skeleton.Skeleton;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvFileSource;
import org.llorllale.cactoos.matchers.Assertion;
import org.llorllale.cactoos.matchers.ScalarHasValue;

/**
* Test case for {@link Lcom4}.
* @since 0.30.9
* @todo #412:30min The methodMethodCalls test is asserting the expected LCOM4 value
* for MethodMethodCalls. Let's have more test cases for LCOM4 metric
* to cover more realistic cases.
*/
public final class Lcom4Test {

Expand All @@ -65,18 +65,19 @@ public void createsXmlCalculusWithXpaths() throws IOException {
).affirm();
}

@Test
@ParameterizedTest
@Disabled
public void methodMethodCalls() throws Exception {
@CsvFileSource(resources = "/org/jpeek/calculus/java/lcom4-params.csv")
public void calculatesValue(final String file, final String value) throws Exception {
final XML result = new Lcom4().node(
Copy link

@fevzian fevzian Mar 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HDouss I think Lcom4 should have a constructor or several constructors to accept parameters and the only its interfaced method node should be parameterless.
I mean, Calculus should have:

public interface Calculus {
   
    XML node()
        throws IOException;

}

and Lcom4 should have a cosntructor to accept the values.

So, I suggest leaving a todo

"", new HashMap<>(0), new Skeleton(
new FakeBase("MethodMethodCalls")
new FakeBase(file)
).xml()
);
new Assertion<>(
"Must create LCOM4 value",
result.xpath("/metric/app/package/class/@value").get(0),
new IsEqual<>("1")
new ItemAt<>(0, result.xpath("/metric/app/package/class/@value")),
new ScalarHasValue<>(value)
).affirm();
}
}
6 changes: 6 additions & 0 deletions src/test/resources/org/jpeek/calculus/java/lcom4-params.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
MethodMethodCalls,2
TwoCommonAttributes,2
TwoCommonMethods,2
OverloadMethods,1
OneCommonAttribute,1
MethodsWithDiffParamTypes,4