Skip to content
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
Expand Up @@ -33,7 +33,6 @@
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.RandomStringUtils;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

import com.researchspace.dataverse.entities.Dataset;
Expand Down Expand Up @@ -67,10 +66,8 @@ public void testListDatasets() {
assertTrue(results.size() > 0);
}

//TODO figure out why data is invalid
@Test
@Ignore("this test fails with message: Error parsing Json: incorrect multiple for field collectionMode")
public void testPostSampleDataset() throws IOException, InterruptedException, URISyntaxException {
public void testPostSampleDataset() throws IOException {
final String toPost = FileUtils.readFileToString(exampleDatasetJson);
final Identifier datasetId = dataverseOps.createDataset(toPost, dataverseAlias);
assertNotNull(datasetId.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,24 @@
public class DataverseOperationsTest extends AbstractIntegrationTest {

/**
* Not found error.
* Not permitted error.
*/
private static final String NOT_FOUND = "Not Found";
private static final String UNAUTHORIZED = "is not permitted to perform requested action";

/**
* Not found error code.
* Not permitted error code.
*/
private static final Integer NOT_FOUND_CODE = 404;
private static final Integer UNAUTHORIZED_CODE = 401;

/**
* Not published error.
*/
private static final String NOT_PUBLISHED = "may not be published because its host dataverse";

/**
* Not published part 2 error.
*/
private static final String NOT_PUBLISHED_2 = "has not been published";

@Before
public void setup() throws Exception {
Expand All @@ -66,8 +76,15 @@ public void createPublishAndDeleteNewDataverse(){
final DataverseResponse<DataversePost> success = dataverseOps.createNewDataverse(dataverseAlias, dv);
assertNotNull(success.getData());
assertNotNull(success.getData().getId());
try {

dataverseOps.publishDataverse(dvName);
dataverseOps.publishDataverse(dvName);
} catch (final RestClientException e) {
assertTrue("[" + e.getLocalizedMessage() + "] should contain ["
+ NOT_PUBLISHED + "] & [" + NOT_PUBLISHED_2 + "]",
e.getLocalizedMessage().contains(NOT_PUBLISHED)
&& e.getLocalizedMessage().contains(NOT_PUBLISHED_2));
}

final DataverseResponse<DvMessage> deleted = dataverseOps.deleteDataverse(dvName);
assertTrue(deleted.getStatus().equals("OK"));
Expand All @@ -89,8 +106,9 @@ public void deleteUnknownDataverseHandled() {
dataverseOps.deleteDataverse("ra");
} catch (final RestClientException e) {
exception = e;
assertEquals(NOT_FOUND_CODE, e.getCode());
assertEquals(NOT_FOUND, e.getLocalizedMessage());
assertEquals(UNAUTHORIZED_CODE, e.getCode());
assertTrue("[" + e.getLocalizedMessage() + "] should contain [" + UNAUTHORIZED + "]",
e.getLocalizedMessage().contains(UNAUTHORIZED));
}
assertNotNull(exception);
}
Expand Down
Loading