Write simple Testcase for ci/cd
This commit is contained in:
parent
1b31a9239c
commit
2c23952a5e
@ -5,12 +5,13 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Fix marking finished task as overdue">
|
<list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Fix marking finished task as overdue">
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/test/java/core/users/UserRepositoryTests.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/test/resources/application.properties" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/java/core/repositories/timemanager/TaskRepository.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/repositories/timemanager/TaskRepository.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/java/core/services/TaskService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/services/TaskService.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main/java/core/DemoApplication.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/DemoApplication.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/../frontend/src/app/app-routing.module.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/app-routing.module.ts" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main/java/core/entities/User.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/entities/User.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/../frontend/src/app/app.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/app.component.html" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/../frontend/src/app/app.module.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/app.module.ts" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -46,35 +47,52 @@
|
|||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent">{
|
<component name="PropertiesComponent"><![CDATA[{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"RequestMappingsPanelOrder0": "0",
|
"RequestMappingsPanelOrder0": "0",
|
||||||
"RequestMappingsPanelOrder1": "1",
|
"RequestMappingsPanelOrder1": "1",
|
||||||
"RequestMappingsPanelWidth0": "75",
|
"RequestMappingsPanelWidth0": "75",
|
||||||
"RequestMappingsPanelWidth1": "75",
|
"RequestMappingsPanelWidth1": "75",
|
||||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"WebServerToolWindowFactoryState": "false",
|
"WebServerToolWindowFactoryState": "false",
|
||||||
"extract.method.default.visibility": "private",
|
"extract.method.default.visibility": "private",
|
||||||
"git-widget-placeholder": "issue-11-angular-update",
|
"git-widget-placeholder": "tests",
|
||||||
"last_directory_selection": "D:/Programmierprojekte/TimeManager/backend/src/main/java/core/api/models/timemanager",
|
"ignore.virus.scanning.warn.message": "true",
|
||||||
"last_opened_file_path": "D:/Programmierprojekte/Dicewars/client",
|
"last_directory_selection": "D:/Programmierprojekte/TimeManager/backend/src/main/java/core/api/models/timemanager",
|
||||||
"node.js.detected.package.eslint": "true",
|
"last_opened_file_path": "D:/Programmierprojekte/Dicewars/client",
|
||||||
"node.js.detected.package.tslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"node.js.detected.package.tslint": "true",
|
||||||
"node.js.selected.package.tslint": "(autodetect)",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
"nodejs_package_manager_path": "npm",
|
"node.js.selected.package.tslint": "(autodetect)",
|
||||||
"settings.editor.selected.configurable": "swagger",
|
"nodejs_package_manager_path": "npm",
|
||||||
"ts.external.directory.path": "/snap/intellij-idea-ultimate/459/plugins/javascript-impl/jsLanguageServicesImpl/external",
|
"settings.editor.selected.configurable": "swagger",
|
||||||
"vue.rearranger.settings.migration": "true"
|
"ts.external.directory.path": "/snap/intellij-idea-ultimate/459/plugins/javascript-impl/jsLanguageServicesImpl/external",
|
||||||
|
"vue.rearranger.settings.migration": "true"
|
||||||
},
|
},
|
||||||
"keyToStringList": {
|
"keyToStringList": {
|
||||||
"DatabaseDriversLRU": [
|
"DatabaseDriversLRU": [
|
||||||
"mariadb"
|
"mariadb"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}</component>
|
}]]></component>
|
||||||
<component name="RunManager">
|
<component name="RunManager" selected="JUnit.UserRepositoryTests.test_findByUsername">
|
||||||
|
<configuration name="UserRepositoryTests.test_findByUsername" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
|
||||||
|
<module name="demo" />
|
||||||
|
<extension name="coverage">
|
||||||
|
<pattern>
|
||||||
|
<option name="PATTERN" value="core.users.*" />
|
||||||
|
<option name="ENABLED" value="true" />
|
||||||
|
</pattern>
|
||||||
|
</extension>
|
||||||
|
<option name="PACKAGE_NAME" value="core.users" />
|
||||||
|
<option name="MAIN_CLASS_NAME" value="core.users.UserRepositoryTests" />
|
||||||
|
<option name="METHOD_NAME" value="test_findByUsername" />
|
||||||
|
<option name="TEST_OBJECT" value="method" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="Make" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
<configuration name="DemoApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true">
|
<configuration name="DemoApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true">
|
||||||
<module name="demo" />
|
<module name="demo" />
|
||||||
<option name="SPRING_BOOT_MAIN_CLASS" value="core.DemoApplication" />
|
<option name="SPRING_BOOT_MAIN_CLASS" value="core.DemoApplication" />
|
||||||
@ -82,6 +100,11 @@
|
|||||||
<option name="Make" enabled="true" />
|
<option name="Make" enabled="true" />
|
||||||
</method>
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
<recent_temporary>
|
||||||
|
<list>
|
||||||
|
<item itemvalue="JUnit.UserRepositoryTests.test_findByUsername" />
|
||||||
|
</list>
|
||||||
|
</recent_temporary>
|
||||||
</component>
|
</component>
|
||||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||||
<component name="TaskManager">
|
<component name="TaskManager">
|
||||||
@ -111,6 +134,7 @@
|
|||||||
<workItem from="1698499063683" duration="8312000" />
|
<workItem from="1698499063683" duration="8312000" />
|
||||||
<workItem from="1698557538577" duration="18000" />
|
<workItem from="1698557538577" duration="18000" />
|
||||||
<workItem from="1698557567325" duration="1724000" />
|
<workItem from="1698557567325" duration="1724000" />
|
||||||
|
<workItem from="1699205483652" duration="1800000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00001" summary="Structure Taskgroups in Hierarchies">
|
<task id="LOCAL-00001" summary="Structure Taskgroups in Hierarchies">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
@ -325,6 +349,11 @@
|
|||||||
<line>202</line>
|
<line>202</line>
|
||||||
<option name="timeStamp" value="10" />
|
<option name="timeStamp" value="10" />
|
||||||
</line-breakpoint>
|
</line-breakpoint>
|
||||||
|
<line-breakpoint enabled="true" type="java-line">
|
||||||
|
<url>file://$PROJECT_DIR$/src/main/java/core/entities/User.java</url>
|
||||||
|
<line>56</line>
|
||||||
|
<option name="timeStamp" value="12" />
|
||||||
|
</line-breakpoint>
|
||||||
</breakpoints>
|
</breakpoints>
|
||||||
</breakpoint-manager>
|
</breakpoint-manager>
|
||||||
</component>
|
</component>
|
||||||
|
@ -54,6 +54,12 @@
|
|||||||
<artifactId>jjwt</artifactId>
|
<artifactId>jjwt</artifactId>
|
||||||
<version>0.9.1</version>
|
<version>0.9.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.h2database</groupId>
|
||||||
|
<artifactId>h2</artifactId>
|
||||||
|
<version>1.3.176</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -18,7 +18,7 @@ public class DemoApplication{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
/*@Bean
|
||||||
public CommandLineRunner init(RoleRepository roleRepository, UserRepository userRepository, PropertyService propertyService) {
|
public CommandLineRunner init(RoleRepository roleRepository, UserRepository userRepository, PropertyService propertyService) {
|
||||||
return args -> {
|
return args -> {
|
||||||
for (UserRole userRole : UserRole.values()) {
|
for (UserRole userRole : UserRole.values()) {
|
||||||
@ -32,5 +32,5 @@ public class DemoApplication{
|
|||||||
FirstUserObserver observer = new FirstUserObserver(userRepository);
|
FirstUserObserver observer = new FirstUserObserver(userRepository);
|
||||||
observer.start();
|
observer.start();
|
||||||
};
|
};
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import javax.validation.constraints.Email;
|
|||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@ -50,6 +51,13 @@ public class User {
|
|||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public User(Long id, String username, String email, String password) {
|
||||||
|
this.id = id;
|
||||||
|
this.username = username;
|
||||||
|
this.email = email;
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@ -89,4 +97,17 @@ public class User {
|
|||||||
public void setRoles(Set<RoleEntity> roles) {
|
public void setRoles(Set<RoleEntity> roles) {
|
||||||
this.roles = roles;
|
this.roles = roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
User user = (User) o;
|
||||||
|
return Objects.equals(id, user.id) && Objects.equals(username, user.username) && Objects.equals(email, user.email) && Objects.equals(password, user.password) && Objects.equals(roles, user.roles);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, username, email, password, roles);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
37
backend/src/test/java/core/users/UserRepositoryTests.java
Normal file
37
backend/src/test/java/core/users/UserRepositoryTests.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package core.users;
|
||||||
|
|
||||||
|
import core.entities.User;
|
||||||
|
import core.repositories.UserRepository;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||||
|
import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager;
|
||||||
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
@DataJpaTest
|
||||||
|
@DirtiesContext
|
||||||
|
@ExtendWith(SpringExtension.class)
|
||||||
|
public class UserRepositoryTests {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserRepository userRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TestEntityManager testEntityManager;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void test_findByUsername() {
|
||||||
|
assertTrue(userRepository.findByUsername("FawKes100").isEmpty());
|
||||||
|
userRepository.save(new User(1L,"FawKes100", "mail@fawkes100.de", "123456"));
|
||||||
|
|
||||||
|
Optional<User> findResult = userRepository.findByUsername("FawKes100");
|
||||||
|
assertTrue(findResult.isPresent());
|
||||||
|
assertEquals(new User(1L, "FawKes100", "mail@fawkes100.de", "123456"),findResult.get());
|
||||||
|
}
|
||||||
|
}
|
7
backend/src/test/resources/application.properties
Normal file
7
backend/src/test/resources/application.properties
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
spring.datasource.driverClassName=org.h2.Driver
|
||||||
|
spring.datasource.url=jdbc:h2:file:~/testdb;MODE=LEGACY
|
||||||
|
spring.h2.console.enabled=true
|
||||||
|
spring.h2.console.path=/console
|
||||||
|
spring.flyway.enabled=false
|
||||||
|
spring.liquibase.enabled=false
|
||||||
|
hibernate.dialect=org.hibernate.dialect.H2Dialect
|
Loading…
Reference in New Issue
Block a user