Formatted code

This commit is contained in:
Luca Frosini 2019-09-16 14:50:08 +02:00
parent 11cd97e1c7
commit f06002302c
9 changed files with 43 additions and 56 deletions

View File

@ -29,7 +29,6 @@ public class CKANPackageTest extends ContextTest {
private static final String LICENSE_VALUE = "CC-BY-SA-4.0"; private static final String LICENSE_VALUE = "CC-BY-SA-4.0";
private static final String EXTRAS_TYPE_VALUE_VALUE = "TestEmptyProfile"; private static final String EXTRAS_TYPE_VALUE_VALUE = "TestEmptyProfile";
@Test @Test
public void list() throws Exception { public void list() throws Exception {
CKANPackage ckanPackage = new CKANPackage(); CKANPackage ckanPackage = new CKANPackage();
@ -67,9 +66,13 @@ public class CKANPackageTest extends ContextTest {
stringsToTest.put("t", false); // Fails because is too short. Min length is 2 characters stringsToTest.put("t", false); // Fails because is too short. Min length is 2 characters
stringsToTest.put("te", true); stringsToTest.put("te", true);
stringsToTest.put("test-test_test-test", true); stringsToTest.put("test-test_test-test", true);
stringsToTest.put("test-test_test-test_test-test_test-test_test-test_test-test_test-test_test-test_test-test_test-test_", true); stringsToTest.put(
"test-test_test-test_test-test_test-test_test-test_test-test_test-test_test-test_test-test_test-test_",
true);
// // Fails because is too long. Max length is 100 characters // // Fails because is too long. Max length is 100 characters
stringsToTest.put("test-test_test-test_test-test_test-test_test-test_test-test_test-test_test-test_test-test_test-test_t", false); stringsToTest.put(
"test-test_test-test_test-test_test-test_test-test_test-test_test-test_test-test_test-test_test-test_t",
false);
for(String testString : stringsToTest.keySet()) { for(String testString : stringsToTest.keySet()) {
boolean match = testString.matches(CKANPackage.NAME_REGEX); boolean match = testString.matches(CKANPackage.NAME_REGEX);
@ -79,7 +82,6 @@ public class CKANPackageTest extends ContextTest {
} }
protected CKANPackage createPackage(ObjectMapper mapper) throws Exception { protected CKANPackage createPackage(ObjectMapper mapper) throws Exception {
ObjectNode itemObjectNode = mapper.createObjectNode(); ObjectNode itemObjectNode = mapper.createObjectNode();
@ -180,7 +182,6 @@ public class CKANPackageTest extends ContextTest {
String gotUpdatedNotes = updatedItemObjectNode.get(NOTES_KEY).asText(); String gotUpdatedNotes = updatedItemObjectNode.get(NOTES_KEY).asText();
Assert.assertTrue(gotUpdatedNotes.compareTo(updatedNotes) == 0); Assert.assertTrue(gotUpdatedNotes.compareTo(updatedNotes) == 0);
ckanPackage = new CKANPackage(); ckanPackage = new CKANPackage();
ckanPackage.setName(ITEM_NAME_VALUE); ckanPackage.setName(ITEM_NAME_VALUE);
((ObjectNode) updatedItemObjectNode).remove(CKANPackage.RESOURCES_KEY); ((ObjectNode) updatedItemObjectNode).remove(CKANPackage.RESOURCES_KEY);

View File

@ -65,14 +65,12 @@ public class CKANUserTest extends ContextTest {
ckanUser.delete(false); ckanUser.delete(false);
} }
@Test @Test
public void testAddSpecialUserToOrganization() throws Exception { public void testAddSpecialUserToOrganization() throws Exception {
CKANUser ckanUser = getCKANUser(); CKANUser ckanUser = getCKANUser();
ckanUser.addUserToOrganization(); ckanUser.addUserToOrganization();
} }
@Test @Test
public void checkAndUpdateInformation() throws Exception { public void checkAndUpdateInformation() throws Exception {
CKANUser ckanUser = CKANUserCache.getCurrrentCKANUser(); CKANUser ckanUser = CKANUserCache.getCurrrentCKANUser();

View File

@ -19,6 +19,4 @@ public class CKANUtilityTest extends ContextTest {
logger.debug("User {} has the following API key {}", CKANUser.getCKANUsername(), ckanAPI); logger.debug("User {} has the following API key {}", CKANUser.getCKANUsername(), ckanAPI);
} }
} }

View File

@ -25,7 +25,6 @@ public class ProfileTest extends ContextTest {
logger.debug("{}", arrayNode); logger.debug("{}", arrayNode);
} }
@Test @Test
public void read() throws Exception { public void read() throws Exception {
String profileID = "EmptyProfile"; String profileID = "EmptyProfile";
@ -75,8 +74,7 @@ public class ProfileTest extends ContextTest {
@Test @Test
public void testCreateUpdateDeleteGenericResource() throws Exception { public void testCreateUpdateDeleteGenericResource() throws Exception {
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(PROFILE_EXAMPLE_FILENAME); InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(PROFILE_EXAMPLE_FILENAME);
String xml = new BufferedReader(new InputStreamReader(inputStream)).lines() String xml = new BufferedReader(new InputStreamReader(inputStream)).lines().collect(Collectors.joining("\n"));
.collect(Collectors.joining("\n"));
logger.debug("Body\n{}", xml); logger.debug("Body\n{}", xml);
ISProfile profile = new ISProfile(); ISProfile profile = new ISProfile();
profile.createOrUpdate(PROFILE_NAME_EXAMPLE, xml); profile.createOrUpdate(PROFILE_NAME_EXAMPLE, xml);

View File

@ -9,12 +9,10 @@ public class ConstantsTest extends ContextTest {
private static final Logger logger = LoggerFactory.getLogger(ConstantsTest.class); private static final Logger logger = LoggerFactory.getLogger(ConstantsTest.class);
@Test @Test
public void testGetApplicationToken() { public void testGetApplicationToken() {
logger.debug("Application token for Context {} is {}", ContextUtility.getCurrentContext(), Constants.getCatalogueApplicationToken()); logger.debug("Application token for Context {} is {}", ContextUtility.getCurrentContext(),
Constants.getCatalogueApplicationToken());
} }
} }

View File

@ -41,11 +41,8 @@ public class CatalogueStorageHubManagementTest extends ContextTest {
public static final String SHORT_URL_STRING = "https://goo.gl/HcUWni"; public static final String SHORT_URL_STRING = "https://goo.gl/HcUWni";
public static final URL SHORT_STORAGE_URL; public static final URL SHORT_STORAGE_URL;
public static final String MIME_TYPE = "application/pdf"; public static final String MIME_TYPE = "application/pdf";
static { static {
try { try {
ORIGINAL_STORAGE_URL = new URL(ORIGINAL_STORAGE_URL_STRING); ORIGINAL_STORAGE_URL = new URL(ORIGINAL_STORAGE_URL_STRING);
@ -63,7 +60,6 @@ public class CatalogueStorageHubManagementTest extends ContextTest {
protected StorageHubManagement storageHubManagement; protected StorageHubManagement storageHubManagement;
protected CatalogueMetadata catalogueMetadata; protected CatalogueMetadata catalogueMetadata;
public CatalogueStorageHubManagementTest() { public CatalogueStorageHubManagementTest() {
catalogueStorageHubManagement = new CatalogueStorageHubManagement(); catalogueStorageHubManagement = new CatalogueStorageHubManagement();
storageHubManagement = catalogueStorageHubManagement.storageHubManagement; storageHubManagement = catalogueStorageHubManagement.storageHubManagement;
@ -82,7 +78,8 @@ public class CatalogueStorageHubManagementTest extends ContextTest {
CatalogueMetadata catalogueMetadata = new CatalogueMetadata(ITEM_ID); CatalogueMetadata catalogueMetadata = new CatalogueMetadata(ITEM_ID);
Metadata expectedMetadata = catalogueMetadata.getMetadata(ORIGINAL_STORAGE_URL, fileContainer.get().getName(), RESOURCE_ID); Metadata expectedMetadata = catalogueMetadata.getMetadata(ORIGINAL_STORAGE_URL, fileContainer.get().getName(),
RESOURCE_ID);
Map<String,Object> expectedMap = expectedMetadata.getMap(); Map<String,Object> expectedMap = expectedMetadata.getMap();
for(String key : gotMap.keySet()) { for(String key : gotMap.keySet()) {
@ -96,28 +93,25 @@ public class CatalogueStorageHubManagementTest extends ContextTest {
} }
} }
@Test @Test
public void testPersistence() throws Exception { public void testPersistence() throws Exception {
URL persistedURL = catalogueStorageHubManagement.ensureResourcePersistence(ORIGINAL_STORAGE_URL, ITEM_ID, RESOURCE_ID); URL persistedURL = catalogueStorageHubManagement.ensureResourcePersistence(ORIGINAL_STORAGE_URL, ITEM_ID,
RESOURCE_ID);
logger.debug("Publick Link of persisted file is {}", persistedURL); logger.debug("Publick Link of persisted file is {}", persistedURL);
Assert.assertTrue(catalogueStorageHubManagement.getMimeType().compareTo(MIME_TYPE) == 0); Assert.assertTrue(catalogueStorageHubManagement.getMimeType().compareTo(MIME_TYPE) == 0);
FileContainer createdFileContainer = storageHubManagement.getCreatedFile(); FileContainer createdFileContainer = storageHubManagement.getCreatedFile();
String version = "2"; String version = "2";
catalogueStorageHubManagement.renameFile(RESOURCE_ID, version); catalogueStorageHubManagement.renameFile(RESOURCE_ID, version);
checkMetadata(createdFileContainer, version); checkMetadata(createdFileContainer, version);
version = "3"; version = "3";
catalogueStorageHubManagement.addRevisionID(RESOURCE_ID, version); catalogueStorageHubManagement.addRevisionID(RESOURCE_ID, version);
checkMetadata(createdFileContainer, version); checkMetadata(createdFileContainer, version);
catalogueStorageHubManagement.deleteResourcePersistence(ITEM_ID, RESOURCE_ID, MIME_TYPE); catalogueStorageHubManagement.deleteResourcePersistence(ITEM_ID, RESOURCE_ID, MIME_TYPE);
} }