Skip to content

Commit

Permalink
adding a few more tests, refs #7
Browse files Browse the repository at this point in the history
changing reporting tool so it works with java8
  • Loading branch information
Idrinth committed Sep 5, 2017
1 parent e3b92b1 commit 2260927
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 132 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ before_install:
- sudo apt-get install jq
- wget -O ~/codacy-coverage-reporter-assembly-latest.jar $(curl https://api.github.com/repos/codacy/codacy-coverage-reporter/releases/latest | jq -r .assets[0].browser_download_url)
after_success:
- java -cp ~/codacy-coverage-reporter-assembly-latest.jar com.codacy.CodacyCoverageReporter -l Java -r target/site/cobertura/coverage.xml
- java -cp ~/codacy-coverage-reporter-assembly-latest.jar com.codacy.CodacyCoverageReporter -l Java -r target/site/jacoco/jacoco.xml
87 changes: 59 additions & 28 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,24 +96,24 @@
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<!--<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.7.1</version>
<scope>test</scope>
<version>2.44.0</version>
</dependency>
<dependency>
<groupId>com.opera</groupId>
<artifactId>operadriver</artifactId>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>1.7.1</version>
<scope>test</scope>
<version>1.5</version>
<exclusions>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependency>-->
<!--<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.8.47</version>
<scope>test</scope>
</dependency>-->
</dependencies>

<organization>
Expand Down Expand Up @@ -222,22 +222,53 @@
</additionalClasspathElements>
</configuration>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<executions>
<execution>
<id>cobertura</id>
<phase>test</phase>
<id>default-prepare-agent</id>
<goals>
<goal>cobertura</goal>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>default-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<outputDirectory>cobertura/</outputDirectory>
<formats>
<format>xml</format>
</formats>
<rules>
<rule>
<element>CLASS</element>
<includes>
<include>de.idrinth.stellaris.modtools*</include>
</includes>
<excludes>
<exclude>*Test</exclude>
<exclude>de.idrinth.stellaris.modtools.entity.*</exclude>
</excludes>
</rule>
<!--<rule implementation="org.jacoco.maven.RuleConfiguration">
<element>BUNDLE</element>
<limits>
<limit implementation="org.jacoco.report.check.Limit">
<counter>COMPLEXITY</counter>
<value>COVEREDRATIO</value>
<minimum>0.95</minimum>
</limit>
</limits>
</rule>-->
</rules>
</configuration>
</execution>
</executions>
Expand All @@ -247,13 +278,13 @@
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<reportSets>
<reportSet>
<reports>
<report>cobertura</report>
<report>report</report>
</reports>
</reportSet>
</reportSets>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,36 +30,47 @@ public Version() {
}

public void addIfBigger(String compareVersion) {
if (isBigger(compareVersion.split("\\."))) {
ArrayList<String> cV = new ArrayList();
CollectionUtils.addAll(cV, compareVersion.split("\\."));
if (isBigger(cV)) {
version.clear();
CollectionUtils.addAll(version, compareVersion.split("\\."));
version.addAll(cV);
while (version.size() < 3) {
version.add("0");
}
}
}

private boolean isBigger(String[] compareVersion) {
private boolean isBigger(ArrayList<String> compareVersion) {
int counter = 0;
for (String part : compareVersion) {
if ("*".equals(part)) {
return true;
int maxCounter = version.size()>compareVersion.size()?version.size():compareVersion.size();
while(compareVersion.size()< maxCounter) {
compareVersion.add("0");
}
while (version.size() < maxCounter) {
version.add("0");
}
while (counter < maxCounter) {
if(compareVersion.size()<= counter) {
compareVersion.add("0");
}
if (version.size() <= counter) {
version.add("0");
}
if ("*".equals(version.get(counter))) {
if("*".equals(version.get(counter)) && "*".equals(compareVersion.get(counter))) {
//this is effectively equal :/
} else if ("*".equals(compareVersion.get(counter))) {
return true;
} else if ("*".equals(version.get(counter))) {
return false;
}
if (Integer.parseInt(part) < Integer.parseInt(version.get(counter))) {
} else if (Integer.parseInt(compareVersion.get(counter)) < Integer.parseInt(version.get(counter))) {
return false;
}
if (Integer.parseInt(part) > Integer.parseInt(version.get(counter))) {
} else if (Integer.parseInt(compareVersion.get(counter)) > Integer.parseInt(version.get(counter))) {
return true;
}
counter++;
}
return version.size() > compareVersion.length;
return false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
package de.idrinth.stellaris.modtools.service;

public class FileExtensions {

private FileExtensions() {
//this is a staatic class only
}

private static final String[] PATCH = ".txt,.yml,.asset,.csv,.gfx,.shader,.fxh,.gui".split(",");
private static final String[] REPLACE = ".wav,.ogg,.ods,.dds,.bmp,.png,.psd,.jpg,.ani,.cur,.ttf,.fnt,.tga,.otf,.anim,.mesh".split(",");
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/META-INF/persistence.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<class>de.idrinth.stellaris.modtools.entity.Original</class>
<class>de.idrinth.stellaris.modtools.entity.Patch</class>
<class>de.idrinth.stellaris.modtools.entity.PatchedFile</class>
<class>de.idrinth.stellaris.modtools.entity.TaskCompletion</class>
<properties>
<!-- Basic Settings -->
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
Expand Down
11 changes: 10 additions & 1 deletion src/test/java/de/idrinth/stellaris/modtools/MainAppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,14 @@ public void testMain() throws NoSuchMethodException {
System.out.println("main");
Assert.assertNotNull("Can't find main method", MainApp.class.getMethod("main",String[].class));
}


/**
* Test of MainApp method, of class MainApp.
* @throws java.lang.NoSuchMethodException
*/
@Test
public void testInstantiation() throws NoSuchMethodException {
System.out.println("MainApp");
Assert.assertNotNull("Can't construct MainApp", new MainApp());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
import org.junit.Test;
import static org.junit.Assert.*;

/**
*
* @author BJ
*/
public class AbstractQueueInitializerTest {
/**
* Test of poll method, of class AbstractQueueInitializer.
Expand Down Expand Up @@ -54,10 +50,25 @@ public void testGetQueueSize() {
assertEquals(20, instance.getQueueSize());
}

public class AbstractQueueInitializerImpl extends AbstractQueueInitializer {
/**
* Test of initOnce method, of class AbstractQueueInitializer.
*/
@Test
public void testInitOnce() {
System.out.println("getQueueSize");
AbstractQueueInitializerImpl instance = new AbstractQueueInitializerImpl();
assertEquals(0, instance.initCalledCount);
instance.hasNext();
assertEquals(1, instance.initCalledCount);
instance.hasNext();
assertEquals(1, instance.initCalledCount);
}

public class AbstractQueueInitializerImpl extends AbstractQueueInitializer {
public volatile int initCalledCount=0;
@Override
public void init() {
//no data to add here
initCalledCount++;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,14 @@ public void testAccept() {
Assert.assertFalse("demo.täxt is ending with.txt?", ff.accept(new File("./"), "demo.täxt"));
Assert.assertFalse("demo.txt.aa is ending with.txt?", ff.accept(new File("./"), "demo.txt.aa"));
}
/**
* Test of FileExtFilter method, of class FileExtFilter.
*/
@Test
public void testFileExtFilter() {
System.out.println("FileExtFilter");
FileExtFilter ff = new FileExtFilter("txt");
Assert.assertNotNull("FileExtFilter wasn't constructed.", ff);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public void testAddIfBigger() {
String v2 = "1.0.2";
String v3 = "1.0.*";
String v4 = "1.1";
String v5 = "1.1.0.2";
Version instance = new Version();
instance.addIfBigger(v1);
Assert.assertEquals("1.0.7 is not more than 1.0.0?",v1,instance.toString());
Expand All @@ -40,6 +41,8 @@ public void testAddIfBigger() {
Assert.assertEquals("1.0.* is not more than 1.0.7?",v3,instance.toString());
instance.addIfBigger(v4);
Assert.assertEquals("1.1 is not more than 1.0.*?",v4+".0",instance.toString());
instance.addIfBigger(v5);
Assert.assertEquals("1.1.0.2 is not more than 1.1.0?",v5,instance.toString());
}

/**
Expand Down

0 comments on commit 2260927

Please sign in to comment.