Skip to content

Commit

Permalink
API Tests fix #124
Browse files Browse the repository at this point in the history
  • Loading branch information
tillias committed Jan 16, 2021
1 parent d3b11bd commit db97dc3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.microcatalog.domain.Microservice;
import com.github.microcatalog.repository.MicroserviceRepository;
import com.github.microcatalog.service.custom.exceptions.ImportException;
import com.github.microcatalog.service.dto.custom.FullMicroserviceDto;
import com.github.microcatalog.service.dto.custom.MicroserviceImportDescriptorDto;
import org.junit.jupiter.api.Test;
Expand All @@ -12,6 +13,7 @@
import java.util.Optional;

import static com.github.microcatalog.service.dto.custom.builder.MicroserviceImportDescriptorDtoBuilder.aMicroserviceImportDescriptorDto;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.BDDMockito.given;
Expand Down Expand Up @@ -39,8 +41,8 @@ void importFromDescriptor_microserviceWithNameAlreadyExists_NoException() {
.withName(name)
.build();

final Optional<FullMicroserviceDto> maybeDto = sut.importFromDescriptor(descriptorDto);
assertFalse(maybeDto.isPresent());
assertThatThrownBy(() -> sut.importFromDescriptor(descriptorDto))
.isInstanceOf(ImportException.class)
.hasMessageStartingWith(String.format("Microservice with name (%s) already exists. Stopping import", name));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ void importFromDescriptor_missingName_Exception() {
.withName(null)
.build();

assertThatThrownBy(() -> sut.importFromDescriptor(descriptorDto)).isInstanceOf(ImportException.class)
assertThatThrownBy(() -> sut.importFromDescriptor(descriptorDto))
.isInstanceOf(ImportException.class)
.hasMessageStartingWith("Microservice name can't be null");
}

Expand Down

0 comments on commit db97dc3

Please sign in to comment.