Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(openchallenges): added unit tests to the image service #2291

Merged
merged 21 commits into from
Nov 3, 2023
Merged
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,58 @@
package org.sagebionetworks.openchallenges.image.service.exception;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.jupiter.api.Test;

public class ImageHeightNotSpecifiedExceptionTest {

@Test
public void ImageHeightNotSpecifiedException_ConstructorTypeShouldMatch() {
// Define the exception detail
String detail = "Image height is not specified";

// Create an instance of ImageHeightNotSpecifiedException
ImageHeightNotSpecifiedException exception = new ImageHeightNotSpecifiedException(detail);

// Verify the exception details
assertThat(ErrorConstants.IMAGE_HEIGHT_NOT_SPECIFIED.getType()).isEqualTo(exception.getType());
}

@Test
public void ImageHeightNotSpecifiedException_ConstructorTitle_Match() {
// Define the exception detail
String detail = "Image height is not specified";

// Create an instance of ImageHeightNotSpecifiedException
ImageHeightNotSpecifiedException exception = new ImageHeightNotSpecifiedException(detail);

// Verify the exception details
assertThat(ErrorConstants.IMAGE_HEIGHT_NOT_SPECIFIED.getTitle())
.isEqualTo(exception.getTitle());
}

@Test
public void ImageHeightNotSpecifiedException_ConstructorStatusMatch() {
// Define the exception detail
String detail = "Image height is not specified";

// Create an instance of ImageHeightNotSpecifiedException
ImageHeightNotSpecifiedException exception = new ImageHeightNotSpecifiedException(detail);

// Verify the exception details
assertThat(ErrorConstants.IMAGE_HEIGHT_NOT_SPECIFIED.getStatus())
.isEqualTo(exception.getStatus());
}

@Test
public void ImageHeightNotSpecifiedException_ConstructorDetailMatch() {
// Define the exception detail
String detail = "Image height is not specified";

// Create an instance of ImageHeightNotSpecifiedException
ImageHeightNotSpecifiedException exception = new ImageHeightNotSpecifiedException(detail);

// Verify the exception details
assertThat(exception.getDetail()).isEqualTo(detail);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package org.sagebionetworks.openchallenges.challenge.service.exception;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.jupiter.api.Test;
import org.sagebionetworks.openchallenges.image.service.exception.SimpleChallengeGlobalException;
import org.springframework.http.HttpStatus;

public class SimpleChallengeGlobalExceptionTest {

@Test
public void SimpleChallengeGlobalException_ConstructorDetailsShouldMatch() {
// Create an instance of SimpleChallengeGlobalException using the constructor with details
String details = "Something went wrong";
SimpleChallengeGlobalException exception = new SimpleChallengeGlobalException(details);

// Verify the exception details
assertThat(exception.getMessage()).isEqualTo(details);
}

@Test
public void SimpleChallengeGlobalException_ConstructorTypeShouldMatch() {
// Define the exception details
String type = "ExceptionType";
String title = "Exception Title";
HttpStatus status = HttpStatus.BAD_REQUEST;
String detail = "Exception detail message";

// Create an instance of SimpleChallengeGlobalException using the all-args constructor
SimpleChallengeGlobalException exception =
new SimpleChallengeGlobalException(type, title, status, detail);

// Verify the exception details
assertThat(exception.getType()).isEqualTo(type);
}

@Test
public void SimpleChallengeGlobalException_ConstructorTitleShouldMatch() {
// Define the exception details
String type = "ExceptionType";
String title = "Exception Title";
HttpStatus status = HttpStatus.BAD_REQUEST;
String detail = "Exception detail message";

// Create an instance of SimpleChallengeGlobalException using the all-args constructor
SimpleChallengeGlobalException exception =
new SimpleChallengeGlobalException(type, title, status, detail);

// Verify the exception details
assertThat(exception.getTitle()).isEqualTo(title);
}

@Test
public void SimpleChallengeGlobalException_ConstructorStatusShouldMatch() {
// Define the exception details
String type = "ExceptionType";
String title = "Exception Title";
HttpStatus status = HttpStatus.BAD_REQUEST;
String detail = "Exception detail message";

// Create an instance of SimpleChallengeGlobalException using the all-args constructor
SimpleChallengeGlobalException exception =
new SimpleChallengeGlobalException(type, title, status, detail);

// Verify the exception details
assertThat(exception.getStatus()).isEqualTo(status);
}
}