-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 1520 gtfs validator desktop app deprecation (#1555)
- Loading branch information
Showing
6 changed files
with
110 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
.../src/main/java/org/mobilitydata/gtfsvalidator/web/service/controller/VersionResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.mobilitydata.gtfsvalidator.web.service.controller; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
public class VersionResponse { | ||
private String version; | ||
} |
54 changes: 54 additions & 0 deletions
54
.../test/java/org/mobilitydata/gtfsvalidator/web/service/controller/VersionEndpointTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.mobilitydata.gtfsvalidator.web.service.controller; | ||
|
||
import static org.mockito.Mockito.*; | ||
|
||
import java.io.IOException; | ||
import java.util.Optional; | ||
import org.junit.jupiter.api.Test; | ||
import org.mobilitydata.gtfsvalidator.util.VersionResolver; | ||
import org.mobilitydata.gtfsvalidator.web.service.util.StorageHelper; | ||
import org.mobilitydata.gtfsvalidator.web.service.util.ValidationHandler; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; | ||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers; | ||
|
||
@WebMvcTest(ValidationController.class) | ||
public class VersionEndpointTest { | ||
@Autowired private MockMvc mockMvc; | ||
@MockBean private StorageHelper storageHelper; | ||
// must be mocked or application context fails to load correctly | ||
@MockBean private ValidationHandler handler; | ||
@MockBean private VersionResolver versionResolver; | ||
|
||
private final String newVersion = "myVersion"; | ||
|
||
@Test | ||
public void testVersionEndpoint() throws Exception { | ||
doReturn(Optional.of(newVersion)).when(versionResolver).resolveCurrentVersion(); | ||
mockMvc | ||
.perform(MockMvcRequestBuilders.get("/version").contentType(MediaType.APPLICATION_JSON)) | ||
.andExpect(MockMvcResultMatchers.status().isOk()) | ||
.andExpect(MockMvcResultMatchers.jsonPath("$.version").isString()) | ||
.andExpect(MockMvcResultMatchers.jsonPath("$.version").value(newVersion)); | ||
} | ||
|
||
@Test | ||
public void testFailedVersionEndpoint() throws Exception { | ||
doThrow(new IOException()).when(versionResolver).resolveCurrentVersion(); | ||
mockMvc | ||
.perform(MockMvcRequestBuilders.get("/version").contentType(MediaType.APPLICATION_JSON)) | ||
.andExpect(MockMvcResultMatchers.status().is5xxServerError()); | ||
} | ||
|
||
@Test | ||
public void testVersionNotFound() throws Exception { | ||
doReturn(Optional.empty()).when(versionResolver).resolveCurrentVersion(); | ||
mockMvc | ||
.perform(MockMvcRequestBuilders.get("/version").contentType(MediaType.APPLICATION_JSON)) | ||
.andExpect(MockMvcResultMatchers.status().is5xxServerError()); | ||
} | ||
} |