-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from aodn/features/5522-update-config-logo
Features/5522 update config logo
- Loading branch information
Showing
13 changed files
with
119 additions
and
35 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
51 changes: 51 additions & 0 deletions
51
...twork-api/src/test/java/au/org/aodn/geonetwork_api/openapi/api/helper/LogoHelperTest.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,51 @@ | ||
package au.org.aodn.geonetwork_api.openapi.api.helper; | ||
|
||
import au.org.aodn.geonetwork_api.openapi.api.LogosApiExt; | ||
import org.apache.commons.io.FileUtils; | ||
import org.junit.Test; | ||
import org.mockito.Mockito; | ||
import org.springframework.core.io.DefaultResourceLoader; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.util.ResourceUtils; | ||
import org.springframework.web.server.ResponseStatusException; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.List; | ||
|
||
import static org.mockito.ArgumentMatchers.*; | ||
import static org.mockito.Mockito.*; | ||
|
||
public class LogoHelperTest { | ||
/** | ||
* The create logo function will try to delete logo before add, this test is used to verify even | ||
* the logo do not exist and not found exception throw from server, the function still works. | ||
*/ | ||
@Test | ||
public void verifyAddNewLogoWorks() throws IOException { | ||
LogosApiExt api = Mockito.mock(LogosApiExt.class); | ||
LogosHelper helper = new LogosHelper(api, new DefaultResourceLoader()); | ||
|
||
when(api.deleteLogoWithHttpInfo(anyString())) | ||
.thenThrow(new ResponseStatusException(HttpStatus.NOT_FOUND, "entity not found")); | ||
|
||
when(api.addLogoWithHttpInfo(any(File.class), anyString(), eq(Boolean.TRUE))) | ||
.thenReturn(ResponseEntity.ok(null)); | ||
|
||
String json1 = FileUtils.readFileToString( | ||
ResourceUtils.getFile("classpath:aad_logo.json"), | ||
StandardCharsets.UTF_8); | ||
|
||
// The logo gif do not exist in the test resources, so this is a negative test case | ||
String json2 = FileUtils.readFileToString( | ||
ResourceUtils.getFile("classpath:not_exist_logo.json"), | ||
StandardCharsets.UTF_8); | ||
|
||
helper.createLogos(List.of(json1, json2)); | ||
|
||
// Only called once because if the logo file not exist then it won't call addLogo | ||
verify(api, times(1)).addLogoWithHttpInfo(any(File.class), anyString(), eq(Boolean.TRUE)); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,5 @@ | ||
{ | ||
"id": "aad_logo", | ||
"image": "AAD_logo.gif", | ||
"link": "classpath:AAD_logo.png" | ||
} |
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,5 @@ | ||
{ | ||
"id": "not_exist_logo", | ||
"image": "not_exist_logo.gif", | ||
"link": "file:not_exist_logo.gif" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"id": "imas_colour_logo", | ||
"image": "IMAS_colour_logo.gif", | ||
"link": "https://content.aodn.org.au/Documents/Images/Logos/AODN_Partner/IMAS_colour_logo.gif" | ||
"image": "IMAS_colour_logo.png", | ||
"link": "https://content.aodn.org.au/Documents/Images/Logos/AODN_Partner/IMAS_colour_logo.png" | ||
} |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"id": "imos_colour_logo", | ||
"image": "IMOS_logo.gif", | ||
"link": "https://content.aodn.org.au/Documents/Images/Logos/IMOS/IMOS_colour_logo.gif" | ||
"image": "IMOS_colour_logo.gif", | ||
"link": "https://content.aodn.org.au/Documents/Images/Logos/AODN_Partner/IMOS_colour_logo.gif" | ||
} |
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
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