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

481prr #78

Closed
wants to merge 9 commits into from
Closed
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
14 changes: 14 additions & 0 deletions resources/testdata/src_changetypes/CommentDeleteFail_Left.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* A class with comments.
*
* @author Beat Fluri
*/
public class ClassWithComments {

public ClassWithComments() {
// a simple method invocation
toString();
}

/* no more methods */
}
14 changes: 14 additions & 0 deletions resources/testdata/src_changetypes/CommentDeleteFail_Right.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* A class with comments.
*
* @author Beat Fluri
*/
public class ClassWithComments {

public ClassWithComments() {
// a simple method
toString();
}

/* no more methods */
}
4 changes: 4 additions & 0 deletions resources/testdata/src_changetypes/CommentDelete_Left.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public class CommentDelete {

public int a = 0;/*Comment to be deleted*/
}
4 changes: 4 additions & 0 deletions resources/testdata/src_changetypes/CommentDelete_Right.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public class CommentDelete {

public int a = 0;
}
40 changes: 40 additions & 0 deletions resources/testdata/src_changetypes/DocDeleteFail_Left.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* A class with comments to associate.
*
* @author Beat Fluri
*/
public class ClassWithCommentsToAssociate {

/**
* Yet another method with a comment
* @param number
* @return
*/
public int foo(int number) {
System.out.println("left");

// THIS WILL BE DELETED
boolean check = number > 0;
int a = 0;
int b = 2;

// check the interesting number
// and some new else

if (check) {
/* A block comment
* with stars
*/
a = 23 + Integer.parseInt("42"); //$NON-NLS-1$
b = Math.round(Math.random() /* inner comment */);
return a + b;
} else {
/* inside else */
b = Math.abs(number);
String.valueOf(true);
b = Math.abs(number);
return b;
}
}

}
39 changes: 39 additions & 0 deletions resources/testdata/src_changetypes/DocDeleteFail_Right.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* A class with comments to associate.
*
* @author Beat Fluri
*/
public class ClassWithCommentsToAssociate {

/**
* Yet another method with a comment
* @param number
* @return
*/
public int foo(int number) {
System.out.println("left");

boolean check = number > 0;
int a = 0;
int b = 2;

// check the interesting number
// and some new else

if (check) {
/* A block comment
* with stars
*/
a = 23 + Integer.parseInt("42"); //$NON-NLS-1$
b = Math.round(Math.random() /* inner comment */);
return a + b;
} else {
/* inside else */
b = Math.abs(number);
String.valueOf(true);
b = Math.abs(number);
return b;
}
}

}
7 changes: 7 additions & 0 deletions resources/testdata/src_changetypes/DocDelete_Left.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

public class DocDelete {
/**
* This is a documentation
*/
public void doc() {};
}
5 changes: 5 additions & 0 deletions resources/testdata/src_changetypes/DocDelete_Right.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

public class DocDelete {

public void doc() {};
}
8 changes: 8 additions & 0 deletions resources/testdata/src_changetypes/MethodRenaming_Left.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package test;
public class Test {

public void method1(){

}

}
8 changes: 8 additions & 0 deletions resources/testdata/src_changetypes/MethodRenaming_Right.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package test;
public class Test {

public void method2(){

}

}
6 changes: 6 additions & 0 deletions resources/testdata/src_changetypes/ParameterInsert_Left.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public class Test {

public void testMethod(){

}
}
6 changes: 6 additions & 0 deletions resources/testdata/src_changetypes/ParameterInsert_Right.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public class Test {

public void testMethod(int n1){

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public class Test {

public void testMethod(String s1,int n1){

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public class Test {

public void testMethod(int n1,String s1){

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package test;
public class Test {

public void method(){

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package test;
public final class Test {

public void method(){

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package test;
public class Test {

public void method(){

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package test;
public class Test {

public static void method(){

}

}
10 changes: 10 additions & 0 deletions resources/testdata/src_changetypes/ReturnTypeDelete_Left.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package test;
public class Test {

public int count(){
System.out.println("No integer counter ");
return 1;

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package test;
public class Test {

public void method2(){
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
package ch.uzh.ifi.seal.changedistiller.unittest;

/*
* #%L
* ChangeDistiller
* %%
* Copyright (C) 2011 - 2018 Software Architecture and Evolution Lab, Department of Informatics, UZH
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/

import static org.junit.Assert.assertEquals;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package ch.uzh.ifi.seal.changedistiller.unittest;

/*
* #%L
* ChangeDistiller
* %%
* Copyright (C) 2011 - 2018 Software Architecture and Evolution Lab, Department of Informatics, UZH
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;

import java.util.List;

import org.junit.Before;
import org.junit.Test;

import ch.uzh.ifi.seal.changedistiller.model.entities.SourceCodeChange;

public class CommentDeleteTest {
List<SourceCodeChange> sourceCodeChangeList, sourceCodeChangeList2;

@Before
public void setUp() {
sourceCodeChangeList = FileDistillerUtil.getChangesFromFile("CommentDelete_Left.java", "CommentDelete_Right.java");
}

@Before
public void setUp2() {
sourceCodeChangeList2 = FileDistillerUtil.getChangesFromFile("CommentDeleteFail_Left.java", "CommentDeleteFail_Right.java");
}

@Test
public void commentDeleteTest() {
String expected = "COMMENT_DELETE\n";

StringBuilder stringBuilder = new StringBuilder();
for(SourceCodeChange change : sourceCodeChangeList) {
stringBuilder.append(change.getLabel() + "\n");
}

assertEquals(stringBuilder.toString(), expected);
}

@Test
public void commentDeleteTestFail() {
String expected = "COMMENT_DELETE\n";

StringBuilder stringBuilder = new StringBuilder();
for(SourceCodeChange change : sourceCodeChangeList) {
stringBuilder.append(change.getLabel() + "\n");
}

assertNotEquals(stringBuilder.toString(), expected);
}
}
Loading