tests and PMD and coverage

This commit is contained in:
anhefti 2019-09-11 12:59:43 +02:00
parent f0fcbefdbb
commit 99d2faf97d
9 changed files with 29 additions and 32 deletions

View file

@ -15,6 +15,8 @@
<rule ref="category/java/errorprone.xml" > <rule ref="category/java/errorprone.xml" >
<exclude name="AvoidDuplicateLiterals"/> <exclude name="AvoidDuplicateLiterals"/>
<exclude name="BeanMembersShouldSerialize"/> <exclude name="BeanMembersShouldSerialize"/>
<exclude name="AvoidFieldNameMatchingMethodName"/>
<exclude name="NullAssignment"/>
</rule> </rule>
</ruleset> </ruleset>

14
pom.xml
View file

@ -173,14 +173,6 @@
<goals> <goals>
<goal>report</goal> <goal>report</goal>
</goals> </goals>
<configuration>
<excludes>
<exclude>ch/ethz/seb/sebserver/gui/content/**/*</exclude>
<exclude>ch/ethz/seb/sebserver/gui/form/**/*</exclude>
<exclude>ch/ethz/seb/sebserver/gui/table/**/*</exclude>
<exclude>ch/ethz/seb/sebserver/gui/widget/**/*</exclude>
</excludes>
</configuration>
</execution> </execution>
<execution> <execution>
<id>post-unit-test</id> <id>post-unit-test</id>
@ -198,9 +190,9 @@
</execution> </execution>
</executions> </executions>
<configuration> <configuration>
<includes> <!-- <includes> -->
<include>ch/ethz/seb/sebserver/*</include> <!-- <include>ch/ethz/seb/sebserver/*</include> -->
</includes> <!-- </includes> -->
<excludes> <excludes>
<exclude>ch/ethz/seb/sebserver/gui/content/**/*</exclude> <exclude>ch/ethz/seb/sebserver/gui/content/**/*</exclude>
<exclude>ch/ethz/seb/sebserver/gui/form/**/*</exclude> <exclude>ch/ethz/seb/sebserver/gui/form/**/*</exclude>

View file

@ -207,8 +207,8 @@ public final class Result<T> {
throw new IllegalArgumentException("Use flatMap instead!"); throw new IllegalArgumentException("Use flatMap instead!");
} }
return Result.of(result); return Result.of(result);
} catch (final Throwable t) { } catch (final Exception e) {
return Result.ofError(t); return Result.ofError(e);
} }
} else { } else {
return Result.ofError(this.error); return Result.ofError(this.error);
@ -230,8 +230,8 @@ public final class Result<T> {
if (this.error == null) { if (this.error == null) {
try { try {
return mapf.apply(this.value); return mapf.apply(this.value);
} catch (final Throwable t) { } catch (final Exception e) {
return Result.ofError(t); return Result.ofError(e);
} }
} else { } else {
return Result.ofError(this.error); return Result.ofError(this.error);

View file

@ -151,6 +151,7 @@ public abstract class AbstractTableFieldBuilder implements InputFieldBuilder {
} }
default: { default: {
item.setText(cellIndex, getValue(attribute, tableValue)); item.setText(cellIndex, getValue(attribute, tableValue));
break;
} }
} }
} }

View file

@ -145,6 +145,8 @@ public class ViewGridBuilder {
break; break;
} }
default: { default: {
// do nothing
break;
} }
} }
} catch (final ArrayIndexOutOfBoundsException e) { } catch (final ArrayIndexOutOfBoundsException e) {

View file

@ -120,7 +120,7 @@ public class ComposerServiceImpl implements ComposerService {
try { try {
composer.compose(pageContext); composer.compose(pageContext);
PageService.updateScrolledComposite(pageContext.getParent()); PageService.updateScrolledComposite(pageContext.getParent());
} catch (final Throwable e) { } catch (final Exception e) {
log.error("Failed to compose: {}, pageContext: {}", name, pageContext, e); log.error("Failed to compose: {}, pageContext: {}", name, pageContext, e);
} }

View file

@ -143,10 +143,10 @@ public final class PageAction {
PageAction.this.pageContext.notifyError("action.error.unexpected.message", restCallError); PageAction.this.pageContext.notifyError("action.error.unexpected.message", restCallError);
} }
return Result.ofError(restCallError); return Result.ofError(restCallError);
} catch (final Throwable t) { } catch (final Exception e) {
log.error("Failed to execute action: {}", PageAction.this, t); log.error("Failed to execute action: {}", PageAction.this, e);
PageAction.this.pageContext.notifyError("action.error.unexpected.message", t); PageAction.this.pageContext.notifyError("action.error.unexpected.message", e);
return Result.ofError(t); return Result.ofError(e);
} }
} }

View file

@ -327,10 +327,10 @@ public class PageContextImpl implements PageContext {
if (returnCode == SWT.OK) { if (returnCode == SWT.OK) {
try { try {
this.onOK.accept(true); this.onOK.accept(true);
} catch (final Throwable t) { } catch (final Exception e) {
log.error( log.error(
"Unexpected on confirm callback execution. This should not happen, plase secure the given onOK Runnable", "Unexpected on confirm callback execution. This should not happen, plase secure the given onOK Runnable",
t); e);
this.onOK.accept(false); this.onOK.accept(false);
} }
} }

View file

@ -115,11 +115,11 @@ public abstract class RestCall<T> {
return handleRestCallError(responseEntity); return handleRestCallError(responseEntity);
} }
} catch (final Throwable t) { } catch (final Exception e) {
final RestCallError restCallError = new RestCallError("Unexpected error while rest call", t); final RestCallError restCallError = new RestCallError("Unexpected error while rest call", e);
try { try {
final String responseBody = ((RestClientResponseException) t).getResponseBodyAsString(); final String responseBody = ((RestClientResponseException) e).getResponseBodyAsString();
restCallError.errors.addAll(RestCall.this.jsonMapper.readValue( restCallError.errors.addAll(RestCall.this.jsonMapper.readValue(
responseBody, responseBody,
@ -127,16 +127,16 @@ public abstract class RestCall<T> {
})); }));
} catch (final ClassCastException cce) { } catch (final ClassCastException cce) {
log.error("Unexpected error-response while webservice API call for: {}", builder, t); log.error("Unexpected error-response while webservice API call for: {}", builder, e);
restCallError.errors.add(APIMessage.ErrorMessage.UNEXPECTED.of(t)); restCallError.errors.add(APIMessage.ErrorMessage.UNEXPECTED.of(e));
} catch (final RuntimeException re) { } catch (final RuntimeException re) {
log.error("Unexpected runtime error while webservice API call for: {}", builder, re); log.error("Unexpected runtime error while webservice API call for: {}", builder, re);
log.error("Unexpected runtime error cause: ", t); log.error("Unexpected runtime error cause: ", e);
restCallError.errors.add(APIMessage.ErrorMessage.UNEXPECTED.of(re)); restCallError.errors.add(APIMessage.ErrorMessage.UNEXPECTED.of(re));
} catch (final Exception e) { } catch (final Exception ee) {
log.error("Unexpected error while webservice API call for: {}", builder, e); log.error("Unexpected error while webservice API call for: {}", builder, ee);
log.error("Unexpected error cause: ", t); log.error("Unexpected error cause: ", e);
restCallError.errors.add(APIMessage.ErrorMessage.UNEXPECTED.of(e)); restCallError.errors.add(APIMessage.ErrorMessage.UNEXPECTED.of(ee));
} }
return Result.ofError(restCallError); return Result.ofError(restCallError);