-
Notifications
You must be signed in to change notification settings - Fork 498
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 #6921 from pkiraly/6920-informative-error-message-…
…for-custom-metadata-block-definition #6920 Informative error message for custom metadata block definition.
- Loading branch information
Showing
7 changed files
with
564 additions
and
7 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
62 changes: 62 additions & 0 deletions
62
src/test/java/edu/harvard/iq/dataverse/api/DatasetFieldServiceApiTest.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,62 @@ | ||
package edu.harvard.iq.dataverse.api; | ||
|
||
import edu.harvard.iq.dataverse.util.BundleUtil; | ||
import org.junit.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class DatasetFieldServiceApiTest { | ||
|
||
@Test | ||
public void testArrayIndexOutOfBoundMessageBundle() { | ||
List<String> arguments = new ArrayList<>(); | ||
arguments.add("DATASETFIELD"); | ||
arguments.add(String.valueOf(5)); | ||
arguments.add("watermark"); | ||
arguments.add(String.valueOf(4 + 1)); | ||
|
||
String bundle = "api.admin.datasetfield.load.ArrayIndexOutOfBoundMessage"; | ||
String message = BundleUtil.getStringFromBundle(bundle, arguments); | ||
assertEquals( | ||
"Error parsing metadata block in DATASETFIELD part, line #5: missing 'watermark' column (#5)", | ||
message | ||
); | ||
} | ||
|
||
@Test | ||
public void testGeneralErrorMessageBundle() { | ||
List<String> arguments = new ArrayList<>(); | ||
arguments.add("DATASETFIELD"); | ||
arguments.add(String.valueOf(5)); | ||
arguments.add("some error message"); | ||
String bundle = "api.admin.datasetfield.load.GeneralErrorMessage"; | ||
String message = BundleUtil.getStringFromBundle(bundle, arguments); | ||
assertEquals( | ||
"Error parsing metadata block in DATASETFIELD part, line #5: some error message", | ||
message | ||
); | ||
} | ||
|
||
@Test | ||
public void testGetArrayIndexOutOfBoundMessage() { | ||
DatasetFieldServiceApi api = new DatasetFieldServiceApi(); | ||
String message = api.getArrayIndexOutOfBoundMessage(DatasetFieldServiceApi.HeaderType.DATASETFIELD, 5, new ArrayIndexOutOfBoundsException("4")); | ||
assertEquals( | ||
"Error parsing metadata block in DATASETFIELD part, line #5: missing 'watermark' column (#5)", | ||
message | ||
); | ||
} | ||
|
||
@Test | ||
public void testGetGeneralErrorMessage() { | ||
DatasetFieldServiceApi api = new DatasetFieldServiceApi(); | ||
String message = api.getGeneralErrorMessage(DatasetFieldServiceApi.HeaderType.DATASETFIELD, 5, "some error"); | ||
assertEquals( | ||
"Error parsing metadata block in DATASETFIELD part, line #5: some error", | ||
message | ||
); | ||
} | ||
} |
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
Oops, something went wrong.