forked from spring-projects/spring-petclinic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Diffblue Cover created unit tests for module spring-petclinic
- Loading branch information
1 parent
21bdf53
commit 1189aa7
Showing
21 changed files
with
2,602 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
src/test/java/org/springframework/samples/petclinic/PetClinicRuntimeHintsDiffblueTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.springframework.samples.petclinic; | ||
|
||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.net.URLClassLoader; | ||
import java.net.URLStreamHandlerFactory; | ||
import java.nio.file.Paths; | ||
import javax.management.loading.MLet; | ||
import org.apache.catalina.webresources.ClasspathURLStreamHandler; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mockito; | ||
import org.springframework.aot.hint.RuntimeHints; | ||
|
||
class PetClinicRuntimeHintsDiffblueTest { | ||
/** | ||
* Method under test: | ||
* {@link PetClinicRuntimeHints#registerHints(RuntimeHints, ClassLoader)} | ||
*/ | ||
@Test | ||
void testRegisterHints() throws MalformedURLException { | ||
// Arrange | ||
PetClinicRuntimeHints petClinicRuntimeHints = new PetClinicRuntimeHints(); | ||
RuntimeHints hints = new RuntimeHints(); | ||
URLStreamHandlerFactory urlStreamHandlerFactory = mock(URLStreamHandlerFactory.class); | ||
when(urlStreamHandlerFactory.createURLStreamHandler(Mockito.<String>any())) | ||
.thenReturn(new ClasspathURLStreamHandler()); | ||
|
||
// Act | ||
petClinicRuntimeHints.registerHints(hints, | ||
new URLClassLoader(new URL[]{Paths.get(System.getProperty("java.io.tmpdir"), "test.txt").toUri().toURL()}, | ||
new MLet(), urlStreamHandlerFactory)); | ||
|
||
// Assert | ||
verify(urlStreamHandlerFactory).createURLStreamHandler(Mockito.<String>any()); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/test/java/org/springframework/samples/petclinic/model/BaseEntityDiffblueTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package org.springframework.samples.petclinic.model; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class BaseEntityDiffblueTest { | ||
/** | ||
* Methods under test: | ||
* | ||
* <ul> | ||
* <li>default or parameterless constructor of {@link BaseEntity} | ||
* <li>{@link BaseEntity#setId(Integer)} | ||
* <li>{@link BaseEntity#getId()} | ||
* </ul> | ||
*/ | ||
@Test | ||
void testGettersAndSetters() { | ||
// Arrange and Act | ||
BaseEntity actualBaseEntity = new BaseEntity(); | ||
actualBaseEntity.setId(1); | ||
|
||
// Assert that nothing has changed | ||
assertEquals(1, actualBaseEntity.getId().intValue()); | ||
} | ||
|
||
/** | ||
* Method under test: {@link BaseEntity#isNew()} | ||
*/ | ||
@Test | ||
void testIsNew() { | ||
// Arrange, Act and Assert | ||
assertTrue((new BaseEntity()).isNew()); | ||
} | ||
|
||
/** | ||
* Method under test: {@link BaseEntity#isNew()} | ||
*/ | ||
@Test | ||
void testIsNew2() { | ||
// Arrange | ||
BaseEntity baseEntity = new BaseEntity(); | ||
baseEntity.setId(1); | ||
|
||
// Act and Assert | ||
assertFalse(baseEntity.isNew()); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/test/java/org/springframework/samples/petclinic/model/NamedEntityDiffblueTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.springframework.samples.petclinic.model; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class NamedEntityDiffblueTest { | ||
/** | ||
* Methods under test: | ||
* | ||
* <ul> | ||
* <li>default or parameterless constructor of {@link NamedEntity} | ||
* <li>{@link NamedEntity#setName(String)} | ||
* <li>{@link NamedEntity#toString()} | ||
* <li>{@link NamedEntity#getName()} | ||
* </ul> | ||
*/ | ||
@Test | ||
void testGettersAndSetters() { | ||
// Arrange and Act | ||
NamedEntity actualNamedEntity = new NamedEntity(); | ||
actualNamedEntity.setName("Bella"); | ||
String actualToStringResult = actualNamedEntity.toString(); | ||
|
||
// Assert that nothing has changed | ||
assertEquals("Bella", actualNamedEntity.getName()); | ||
assertEquals("Bella", actualToStringResult); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/test/java/org/springframework/samples/petclinic/model/PersonDiffblueTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.springframework.samples.petclinic.model; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class PersonDiffblueTest { | ||
/** | ||
* Methods under test: | ||
* | ||
* <ul> | ||
* <li>default or parameterless constructor of {@link Person} | ||
* <li>{@link Person#setFirstName(String)} | ||
* <li>{@link Person#setLastName(String)} | ||
* <li>{@link Person#getFirstName()} | ||
* <li>{@link Person#getLastName()} | ||
* </ul> | ||
*/ | ||
@Test | ||
void testGettersAndSetters() { | ||
// Arrange and Act | ||
Person actualPerson = new Person(); | ||
actualPerson.setFirstName("Jane"); | ||
actualPerson.setLastName("Doe"); | ||
String actualFirstName = actualPerson.getFirstName(); | ||
|
||
// Assert that nothing has changed | ||
assertEquals("Doe", actualPerson.getLastName()); | ||
assertEquals("Jane", actualFirstName); | ||
} | ||
} |
Oops, something went wrong.