Commit b3ba1e4e authored by Marek Skácelík's avatar Marek Skácelík 🫠
Browse files

Merge branch 'user-another-tests' into 'milestone-2'

added some tests for user

See merge request !37
parents 0be5ce05 bd9315aa
Loading
Loading
Loading
Loading
Loading
+5 −23
Original line number Diff line number Diff line
@@ -23,6 +23,11 @@
            <artifactId>postgresql</artifactId>
            <version>42.5.4</version>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
@@ -41,12 +46,6 @@
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>RELEASE</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
@@ -64,23 +63,6 @@
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.springdoc</groupId>
                <artifactId>springdoc-openapi-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <apiDocsUrl>http://localhost:8080/openapi.yaml</apiDocsUrl>
                    <outputFileName>openapi.yaml</outputFileName>
                    <outputDir>..</outputDir>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
 No newline at end of file
+2 −0
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@ package cz.muni.fi.pa165.core;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;

@SpringBootApplication
public class CoreApplication {
+1 −2
Original line number Diff line number Diff line
@@ -23,9 +23,8 @@ import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@RequiredArgsConstructor
@Component
@RequiredArgsConstructor
public class DataInitializer implements ApplicationRunner {
  private final UserService userService;
  private final DeviceService deviceService;
+1 −5
Original line number Diff line number Diff line
@@ -91,11 +91,7 @@ public abstract class DomainFacade<E extends DomainObject,
	 * @return the DTO representation of the created entity
	 */
	public T create(C createDto) {
		try {
		return mapper.toDto(service.create(mapper.fromCreateDto(createDto)));
		} catch (DataIntegrityViolationException e) {
			throw new ResponseStatusException(HttpStatus.CONFLICT, "Entity with the same name already exists", e);
		}
	}

	/**
+3 −1
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ public abstract class DomainService<T extends DomainObject> {
				.orElseThrow(() -> new EntityNotFoundException("Entity with '" + id + "' not found."));
	}


	/**
	 * Deletes all entities by setting their deletion datetime.
	 */
@@ -141,11 +142,12 @@ public abstract class DomainService<T extends DomainObject> {
		return entity;
	}


	/**
	 * Deletes all entities from the database without soft-delete functionality.
	 */
	@Transactional
	public void deleteAllHardDelete() {
	public void hardDeleteAll() {
		getRepository().deleteAll();
	}
}
Loading