Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.springframework.samples.petclinic;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.samples.petclinic.model.BaseEntity;
import org.springframework.samples.petclinic.model.Person;
import org.springframework.samples.petclinic.vet.Vet;

import static org.mockito.Mockito.verify;

public class PetClinicRuntimeHints_registerHints_b9a071d40e_Test {

@Mock
private RuntimeHints hints;

@BeforeEach
public void setup() {
MockitoAnnotations.openMocks(this);
}

@Test
public void testRegisterHints() {
PetClinicRuntimeHints_registerHints_b9a071d40e registerHints = new PetClinicRuntimeHints_registerHints_b9a071d40e();
registerHints.registerHints(hints, this.getClass().getClassLoader());

verify(hints).resources().registerPattern("db/*");
verify(hints).resources().registerPattern("messages/*");
verify(hints).resources().registerPattern("META-INF/resources/webjars/*");
verify(hints).resources().registerPattern("mysql-default-conf");
verify(hints).serialization().registerType(BaseEntity.class);
verify(hints).serialization().registerType(Person.class);
verify(hints).serialization().registerType(Vet.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.springframework.samples.petclinic.model;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.when;

public class BaseEntity_getId_09ace845cd_Test {

@Mock
private BaseEntity baseEntity;

@InjectMocks
BaseEntity_getId_09ace845cd_Test baseEntity_getId_09ace845cd_Test;

@BeforeEach
public void setup() {
MockitoAnnotations.openMocks(this);
when(baseEntity.getId()).thenReturn(1);
}

@Test
public void testGetIdSuccess() {
assertEquals(1, baseEntity.getId().intValue(), "Expected and actual id do not match.");
}

@Test
public void testGetIdFailure() {
when(baseEntity.getId()).thenReturn(null);
assertEquals(null, baseEntity.getId(), "Expected null but got a value.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.springframework.samples.petclinic.model;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class BaseEntity_getTest_cb622c11b2_Test {

private BaseEntity baseEntity;

@BeforeEach
public void setup() {
baseEntity = new BaseEntity();
}

@Test
public void testGetTest_WhenTestValueIsSet() {
String expectedValue = "Test Value";
baseEntity.setTest(expectedValue);
String actualValue = baseEntity.getTest();
assertEquals(expectedValue, actualValue);
}

@Test
public void testGetTest_WhenTestValueIsNotSet() {
String actualValue = baseEntity.getTest();
assertEquals(null, actualValue);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.springframework.samples.petclinic.model;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

class BaseEntity_isNew_70b8047511_Test {

private BaseEntity baseEntity;

@BeforeEach
void setUp() {
this.baseEntity = new BaseEntity();
}

@Test
void testIsNew_withNullId() {
this.baseEntity.setId(null);
assertTrue(this.baseEntity.isNew());
}

@Test
void testIsNew_withNonNullId() {
this.baseEntity.setId(1);
assertFalse(this.baseEntity.isNew());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<build>
<plugins>
<plugin>
<groupId>io.spring.javaformat</groupId>
<artifactId>spring-javaformat-maven-plugin</artifactId>
<version>0.0.27</version>
<executions>
<execution>
<goals>
<goal>apply</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.springframework.samples.petclinic.model;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import static org.junit.jupiter.api.Assertions.assertEquals;

@SpringBootTest
public class BaseEntity_setTest_5fff6a653b_Test {

private BaseEntity baseEntity;

private String test;

@BeforeEach
public void setup() {
baseEntity = new BaseEntity();
}

@Test
public void setTest_validInput_testIsSet() {
// assuming BaseEntity has a setTest method
test = "valid input";
baseEntity.setTest(test);
assertEquals(test, baseEntity.getTest(), "Test should be set to 'valid input'");
}

@Test
public void setTest_nullInput_testIsNull() {
// assuming BaseEntity has a setTest method
test = null;
baseEntity.setTest(test);
assertEquals(test, baseEntity.getTest(), "Test should be set to null");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.springframework.samples.petclinic.model;

import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.samples.petclinic.model.NamedEntity;

public class NamedEntity_getName_4ad76af4d7_Test {

private NamedEntity namedEntity;

@BeforeEach
public void setup() {
this.namedEntity = new NamedEntity();
}

@Test
public void testGetName_Success() {
String expectedName = "Test Name";
this.namedEntity.setName(expectedName);
String actualName = this.namedEntity.getName();
assertEquals(expectedName, actualName);
}

@Test
public void testGetName_Null() {
String expectedName = null;
this.namedEntity.setName(expectedName);
String actualName = this.namedEntity.getName();
assertEquals(expectedName, actualName);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.springframework.samples.petclinic.model;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class NamedEntity_setName_f5bd015150_Test {
private NamedEntity namedEntity;

@BeforeEach
public void setUp() {
namedEntity = new NamedEntity();
}

@Test
public void testSetName() {
String expectedName = "Test Name";
namedEntity.setName(expectedName);
assertEquals(expectedName, namedEntity.getName());
}

@Test
public void testSetName_Null() {
String expectedName = null;
namedEntity.setName(expectedName);
assertEquals(expectedName, namedEntity.getName());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.springframework.samples.petclinic.model;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class NamedEntity_toString_2393b88875_Test {

private NamedEntity namedEntity;

@BeforeEach
public void setup() {
namedEntity = new NamedEntity();
}

@Test
public void testToString_WithName() {
namedEntity.setName("TestName");
String result = namedEntity.toString();
assertEquals("TestName", result, "Expected and actual results do not match");
}

@Test
public void testToString_WithoutName() {
namedEntity.setName(null);
String result = namedEntity.toString();
assertEquals(null, result, "Expected and actual results do not match");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.springframework.samples.petclinic.model;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class PersonGetFirstNameTest {

private Person person;

@BeforeEach
public void setup() {
person = new Person();
}

@Test
public void testGetFirstName_WhenFirstNameIsSet() {
String expectedFirstName = "John";
person.setFirstName(expectedFirstName);
String actualFirstName = person.getFirstName();
assertEquals(expectedFirstName, actualFirstName, "First name should match");
}

@Test
public void testGetFirstName_WhenFirstNameIsNotSet() {
String expectedFirstName = null;
String actualFirstName = person.getFirstName();
assertEquals(expectedFirstName, actualFirstName, "First name should be null");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Test generated by RoostGPT for test demo using AI Type Open AI and AI Model gpt-4

package org.springframework.samples.petclinic.model;

import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class Person_getLastName_de1cc748dc_Test {

private Person person;

@BeforeEach
public void setUp() {
this.person = new Person();
}

@Test
public void testGetLastName() {
String expectedLastName = "Smith";
this.person.setLastName(expectedLastName);
String actualLastName = this.person.getLastName();
assertEquals(expectedLastName, actualLastName, "The last name should be Smith");
}

@Test
public void testGetLastNameWhenLastNameIsNull() {
this.person.setLastName(null);
String actualLastName = this.person.getLastName();
assertEquals(null, actualLastName, "The last name should be null");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.springframework.samples.petclinic.model;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class Person_setFirstName_f9bf7d9c2d_Test {

private Person person;

@BeforeEach
public void setup() {
person = new Person();
}

@Test
public void testSetFirstName_Success() {
String firstName = "John";
person.setFirstName(firstName);
assertEquals(firstName, person.getFirstName());
}

@Test
public void testSetFirstName_Null() {
String firstName = null;
person.setFirstName(firstName);
assertEquals(firstName, person.getFirstName());
}
}
Loading