07-FixCompilationWarningsTest

This commit is contained in:
Adrian-Devries 2025-04-24 12:53:55 +02:00
parent adb4effcf9
commit d22b03cec1
17 changed files with 95 additions and 161 deletions

View file

@ -16,16 +16,15 @@
package de.kosit.validationtool.impl;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThrows;
import java.io.Serializable;
import java.net.URISyntaxException;
import java.net.URL;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import de.kosit.validationtool.impl.Helper.Invalid;
import de.kosit.validationtool.impl.Helper.Simple;
@ -40,9 +39,6 @@ public class ConversionServiceTest {
private static final URL SCHEMA = ConversionServiceTest.class.getResource("/xsd/scenarios.xsd");
@Rule
public ExpectedException exception = ExpectedException.none();
private ConversionService service;
private ContentRepository repository;
@ -55,15 +51,15 @@ public class ConversionServiceTest {
@Test
public void testMarshalNull() {
this.exception.expect(ConversionService.ConversionException.class);
this.service.writeXml(null);
assertThrows(ConversionService.ConversionException.class, () -> this.service.writeXml(null));
}
@Test
public void testMarshalUnknown() {
this.exception.expect(ConversionService.ConversionException.class);
this.service.writeXml(new Serializable() {
});
assertThrows(ConversionService.ConversionException.class, () -> this.service.writeXml(new Serializable() {
private static final long serialVersionUID = 8745690876369610705L;
}));
}
@Test
@ -82,32 +78,29 @@ public class ConversionServiceTest {
@Test
public void testUnmarshalInvalidXml() {
this.exception.expect(ConversionService.ConversionException.class);
this.service.readXml(Invalid.SCENARIOS, Scenarios.class, this.repository.createSchema(SCHEMA));
assertThrows(ConversionService.ConversionException.class,
() -> this.service.readXml(Invalid.SCENARIOS, Scenarios.class, this.repository.createSchema(SCHEMA)));
}
@Test
public void testUnmarshalIllFormed() {
this.exception.expect(ConversionService.ConversionException.class);
this.service.readXml(Invalid.SCENARIOS_ILLFORMED, Scenarios.class, this.repository.createSchema(SCHEMA));
assertThrows(ConversionService.ConversionException.class,
() -> this.service.readXml(Invalid.SCENARIOS_ILLFORMED, Scenarios.class, this.repository.createSchema(SCHEMA)));
}
@Test
public void testUnmarshalEmpty() {
this.exception.expect(ConversionService.ConversionException.class);
this.service.readXml(null, Scenarios.class);
assertThrows(ConversionService.ConversionException.class, () -> this.service.readXml(null, Scenarios.class));
}
@Test
public void testUnmarshalUnknownType() throws URISyntaxException {
this.exception.expect(ConversionService.ConversionException.class);
this.service.readXml(Simple.SCENARIOS, ConversionService.class);
assertThrows(ConversionService.ConversionException.class, () -> this.service.readXml(Simple.SCENARIOS, ConversionService.class));
}
@Test
public void testUnmarshalWithoutType() throws URISyntaxException {
this.exception.expect(ConversionService.ConversionException.class);
this.service.readXml(Simple.SCENARIOS, null);
assertThrows(ConversionService.ConversionException.class, () -> this.service.readXml(Simple.SCENARIOS, null));
}
}