Skip to content

Commit

Permalink
fix typos in files for unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsage1 committed Oct 31, 2023
1 parent 1c39ace commit db9607a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.sagebionetworks.openchallenges.image.service.model.dto.ImageAspectRatioDto;

import static org.junit.Assert.assertEquals;

public class ImageAspectRatioDtoTest {

@Test
void GetValueShouldGetSpecifiedNumericCombination() {
public void GetValueShouldGetSpecifiedNumericCombination() {
// Test the getValue() method for each enum value
assertEquals("original", ImageAspectRatioDto.ORIGINAL.getValue());
assertEquals("16_9", ImageAspectRatioDto._16_9.getValue());
Expand All @@ -15,7 +16,7 @@ void GetValueShouldGetSpecifiedNumericCombination() {
}

@Test
void FromValueShouldEqualExpectedValue() {
public void FromValueShouldEqualExpectedValue() {
// Test the fromValue() method for each enum value
assertEquals(ImageAspectRatioDto.ORIGINAL, ImageAspectRatioDto.fromValue("original"));
assertEquals(ImageAspectRatioDto._16_9, ImageAspectRatioDto.fromValue("16_9"));
Expand All @@ -25,8 +26,8 @@ void FromValueShouldEqualExpectedValue() {
}

@Test(expected = IllegalArgumentException.class)
void testFromShouldReturnInvalidValue() {
public void testFromShouldReturnInvalidValue() {
// Test the fromValue() method with an invalid value
ImageAspectRatioDto.fromValue("invalid_value");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;

import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.junit.Test;
import org.mockito.Mock;
import org.sagebionetworks.openchallenges.image.service.api.ApiUtil;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.web.context.request.NativeWebRequest;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;

public class ApiUtilTest {

@Mock private NativeWebRequest nativeWebRequest;
@Mock
private NativeWebRequest nativeWebRequest;

@Test
void SetExampleResponse_ShouldReturnExpectedResponse() throws IOException {
public void SetExampleResponse_ShouldReturnExpectedResponse() throws IOException {
// Create a mock NativeWebRequest
nativeWebRequest = new MockNativeWebRequest();

Expand All @@ -25,8 +28,8 @@ void SetExampleResponse_ShouldReturnExpectedResponse() throws IOException {
String contentType = "application/json";
String example = "{\"key\": \"value\"}";

// Call the setExampleResponse method
ApiUtil.setExampleResponse(nativeWebRequest, contentType, example);
// Call the SetExampleResponse_ShouldReturnExpectedResponse method
ApiUtil.SetExampleResponse_ShouldReturnExpectedResponse(nativeWebRequest, contentType, example);

// Verify the response
assertEquals(contentType, mockResponse.getHeader("Content-Type"));
Expand All @@ -53,5 +56,6 @@ public String getHeader(String name) {
public String[] getHeaderValues(String name) {
return new String[0];
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ public class ImageApiTest {
@Test
public void testGetImage() {
// Create an instance of ImageApi
ImageApi imageApi =
new ImageApi() {
ImageApi imageApi = new ImageApi() {
@Override
public ImageApiDelegate getDelegate() {
return delegate;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

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

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

public class SimpleChallengeGlobalExceptionTest {

@Test
void testConstructorWithDetails() {
public void testConstructorWithDetails() {
// Create an instance of SimpleChallengeGlobalException using the constructor with details
String details = "Something went wrong";
SimpleChallengeGlobalException exception = new SimpleChallengeGlobalException(details);
Expand All @@ -21,16 +22,15 @@ void testConstructorWithDetails() {
}

@Test
void Simpl_ShouldReturnSpecifiedArgs() {
public void SimpleChallenge_ShouldReturnSpecifiedArgs() {
// 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);
SimpleChallengeGlobalException exception = new SimpleChallengeGlobalException(type, title, status, detail);

// Verify the exception details
assertNull(exception.getMessage());
Expand All @@ -39,4 +39,4 @@ void Simpl_ShouldReturnSpecifiedArgs() {
assertEquals(status, exception.getStatus());
assertEquals(detail, exception.getDetail());
}
}
}

0 comments on commit db9607a

Please sign in to comment.