Skip to content
Snippets Groups Projects
Commit 31ec52d9 authored by Martin Weise's avatar Martin Weise
Browse files

minor changes in tests, testing image not found with integration test

parent d0c525e3
No related branches found
No related tags found
6 merge requests!81New stable release,!43Merge dev to master,!23Sprint results,!20Pull Request,!19Pull Request,!18Merge Conflicts
...@@ -118,7 +118,6 @@ public class ContainerEndpointUnitTest extends BaseUnitTest { ...@@ -118,7 +118,6 @@ public class ContainerEndpointUnitTest extends BaseUnitTest {
/* test */ /* test */
final ResponseEntity<ContainerDto> response = containerEndpoint.findById(CONTAINER_1_ID); final ResponseEntity<ContainerDto> response = containerEndpoint.findById(CONTAINER_1_ID);
assertEquals(HttpStatus.OK, response.getStatusCode()); assertEquals(HttpStatus.OK, response.getStatusCode());
assertEquals(CONTAINER_1_ID, Objects.requireNonNull(response.getBody()).getId());
} }
@Test @Test
......
package at.tuwien.service;
import at.tuwien.BaseUnitTest;
import at.tuwien.api.container.ContainerCreateRequestDto;
import at.tuwien.api.container.ContainerStateDto;
import at.tuwien.api.container.image.ImageCreateDto;
import at.tuwien.entities.container.Container;
import at.tuwien.exception.*;
import at.tuwien.repository.ContainerRepository;
import at.tuwien.repository.ImageRepository;
import com.github.dockerjava.api.DockerClient;
import com.github.dockerjava.api.command.CreateContainerResponse;
import com.github.dockerjava.api.exception.NotModifiedException;
import com.github.dockerjava.api.model.HostConfig;
import com.github.dockerjava.api.model.Network;
import com.github.dockerjava.api.model.PortBinding;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
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.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.*;
@ExtendWith(SpringExtension.class)
@SpringBootTest
public class ImageServiceIntegrationTest extends BaseUnitTest {
@Autowired
private ImageService imageService;
@Test
public void test_notFound_fails() {
final ImageCreateDto request = ImageCreateDto.builder()
.repository("s0m3th1ng_n0t3x1st1ng")
.tag("d3v_h3ll")
.defaultPort(IMAGE_1_PORT)
.environment(IMAGE_1_ENV_DTO)
.build();
/* test */
assertThrows(ImageNotFoundException.class, () -> {
imageService.create(request);
});
}
}
...@@ -76,23 +76,6 @@ public class ImageServiceUnitTest extends BaseUnitTest { ...@@ -76,23 +76,6 @@ public class ImageServiceUnitTest extends BaseUnitTest {
}); });
} }
@Test
public void create_notFound_fails() throws ImageNotFoundException {
final ImageCreateDto request = ImageCreateDto.builder()
.repository(IMAGE_1_REPOSITORY)
.tag(IMAGE_1_TAG)
.defaultPort(IMAGE_1_PORT)
.environment(IMAGE_1_ENV_DTO)
.build();
when(imageService.create(request))
.thenThrow(ImageNotFoundException.class);
/* test */
assertThrows(ImageNotFoundException.class, () -> {
imageService.create(request);
});
}
@Test @Test
public void create_duplicate_fails() throws ImageNotFoundException { public void create_duplicate_fails() throws ImageNotFoundException {
final ImageCreateDto request = ImageCreateDto.builder() final ImageCreateDto request = ImageCreateDto.builder()
......
...@@ -55,6 +55,8 @@ public class TableServiceUnitTest extends BaseUnitTest { ...@@ -55,6 +55,8 @@ public class TableServiceUnitTest extends BaseUnitTest {
public void findAll_succeeds() throws TableNotFoundException, DatabaseNotFoundException { public void findAll_succeeds() throws TableNotFoundException, DatabaseNotFoundException {
when(databaseRepository.findById(DATABASE_1_ID)) when(databaseRepository.findById(DATABASE_1_ID))
.thenReturn(Optional.of(DATABASE_1)); .thenReturn(Optional.of(DATABASE_1));
when(tableRepository.findByDatabase(DATABASE_1))
.thenReturn(List.of(TABLE_1));
/* test */ /* test */
final List<Table> response = tableService.findAll(DATABASE_1_ID); final List<Table> response = tableService.findAll(DATABASE_1_ID);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment