Commit bf4a17cf authored by Matija Obreza's avatar Matija Obreza
Browse files

JUnit tests updated

parent b472814c
......@@ -59,13 +59,14 @@ public class AccessionHistoryTest extends GenesysServicesTest {
faoInstitute.setCode(INSTCODE);
instituteService.update(Collections.singletonList(faoInstitute));
faoInstitute = instituteService.getInstitute(faoInstitute.getCode());
taxonomy2 = taxonomyService.internalEnsure("Genus", "species", "", "", "");
country = new Country();
country.setCode3("UKR");
country.setName("Ukraine");
countryRepository.save(country);
country = countryRepository.save(country);
accession = new Accession();
accession.setAccessionId(new AccessionId());
......
......@@ -17,6 +17,7 @@
package org.genesys2.server.service.impl;
import java.io.File;
import java.util.Set;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.SerializationFeature;
......@@ -25,6 +26,7 @@ import com.hazelcast.core.IQueue;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.velocity.app.VelocityEngine;
import org.elasticsearch.common.collect.Sets;
import org.genesys.blocks.security.persistence.AclClassPersistence;
import org.genesys.blocks.security.persistence.AclEntryPersistence;
import org.genesys.blocks.security.persistence.AclObjectIdentityPersistence;
......@@ -83,6 +85,7 @@ import org.genesys2.server.service.ElasticService;
import org.genesys2.server.service.GenesysFilterService;
import org.genesys2.server.service.GenesysRESTService;
import org.genesys2.server.service.GenesysService;
import org.genesys2.server.service.GeoRegionService;
import org.genesys2.server.service.GeoService;
import org.genesys2.server.service.HtmlSanitizer;
import org.genesys2.server.service.InstituteFilesService;
......@@ -98,6 +101,7 @@ import org.genesys2.server.service.TokenVerificationService;
import org.genesys2.server.service.TraitService;
import org.genesys2.server.service.UserService;
import org.genesys2.server.service.worker.ElasticUpdater;
import org.genesys2.server.service.worker.GeoRegionDataCLDR;
import org.genesys2.server.test.PropertyPlacholderInitializer;
import org.genesys2.tests.BaseSpringTest;
import org.junit.runner.RunWith;
......@@ -175,6 +179,16 @@ public abstract class GenesysServicesTest extends BaseSpringTest {
return new GeoServiceImpl();
}
@Bean
public GeoRegionService geoRegionService() {
return new GeoRegionServiceImpl();
}
@Bean
public GeoRegionDataCLDR geoRegionDataCldr() {
return new GeoRegionDataCLDR();
}
@Bean
public CacheManager cacheManager() {
return new NoOpCacheManager();
......@@ -372,6 +386,12 @@ public abstract class GenesysServicesTest extends BaseSpringTest {
public IQueue<Object> elasticUpdateQueue(HazelcastInstance hazelcast) {
return hazelcast.getQueue("es-update");
}
@Bean
public static Set<String> supportedLocales() {
final Set<String> supportedLocales = Sets.newHashSet("en", "es", "de", "fr", "fa", "ar", "ru", "zh", "pt");
return supportedLocales;
}
}
@Autowired
......
......@@ -50,7 +50,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@PropertySource("classpath:/spring/spring.properties")
@EnableJpaRepositories(basePackages = { "org.genesys.blocks.persistence", "org.genesys.blocks.security.persistence", "org.genesys2.server.persistence.acl", "org.genesys2.server.persistence.domain",
@EnableJpaRepositories(basePackages = { "org.genesys.blocks.persistence", "org.genesys.blocks.security.persistence", "org.genesys.filerepository.persistence", "org.genesys2.server.persistence.acl", "org.genesys2.server.persistence.domain",
"org.genesys2.server.filerepository.persistence" }, repositoryImplementationPostfix = "CustomImpl", entityManagerFactoryRef = "entityManagerFactory", transactionManagerRef = "transactionManager")
@EnableTransactionManagement
public class JpaDataConfig {
......@@ -80,7 +80,7 @@ public class JpaDataConfig {
bean.setDataSource(dataSource());
bean.setPersistenceUnitName("spring-jpa");
bean.setPackagesToScan("org.genesys.blocks.model", "org.genesys.blocks.security.model", "org.genesys2.server.model", "org.genesys2.server.filerepository.model");
bean.setPackagesToScan("org.genesys.blocks.model", "org.genesys.blocks.security.model", "org.genesys2.server.model", "org.genesys.filerepository.model");
bean.setPersistenceProvider(new HibernatePersistenceProvider());
final HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();
......
......@@ -258,8 +258,6 @@ public abstract class AbstractRestTest extends BaseSpringTest {
public UserService userService() {
return new UserServiceImpl();
}
@Bean
public PasswordPolicy passwordPolicy() {
......@@ -529,13 +527,13 @@ public abstract class AbstractRestTest extends BaseSpringTest {
@Bean
public GeoRegionService geoRegionService() {
return new GeoRegionServiceImpl();
}
}
@Bean
public GeoRegionDataCLDR geoRegionDataCldr() {
return new GeoRegionDataCLDR();
}
@Bean
public static Set<String> supportedLocales() {
final Set<String> supportedLocales = Sets.newHashSet("en", "es", "de", "fr", "fa", "ar", "ru", "zh", "pt");
......@@ -709,7 +707,7 @@ public abstract class AbstractRestTest extends BaseSpringTest {
@Autowired
protected MaterialSubRequestRepository materialSubRequestRepository;
@Autowired
protected RepositoryFilePersistence repositoryFileRepository;
}
......@@ -42,7 +42,7 @@ public class CacheControllerTest extends AbstractRestTest {
mockMvc.perform(get("/api/v0/cache")
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$.cacheMaps", hasSize(greaterThan(0))))
.andExpect(jsonPath("$.cacheOther", hasSize(0)));
......
......@@ -85,9 +85,9 @@ public class CropsControllerTest extends AbstractRestTest {
LOG.info("Start test-method listCropsTest");
mockMvc.perform(get("/api/v0/crops")
.contentType(MediaType.APPLICATION_JSON))
.contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$", hasSize(1)))
.andExpect(jsonPath("$[0].id", is(notNullValue())))
.andExpect(jsonPath("$[0].version", is(0)))
......@@ -105,14 +105,14 @@ public class CropsControllerTest extends AbstractRestTest {
LOG.info("Start test-method createCropTest");
mockMvc.perform(post("/api/v0/crops")
.contentType(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON_UTF8)
.content(objectMapper.writeValueAsString(new Object() {
public String shortName="rice";
public String name="Rice";
public String description="Crop description in EN";
})))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$.id", is(notNullValue())))
.andExpect(jsonPath("$.version", is(0)))
.andExpect(jsonPath("$.shortName", is("rice")))
......@@ -148,9 +148,9 @@ public class CropsControllerTest extends AbstractRestTest {
LOG.info("Start test-method getCropTest");
mockMvc.perform(get("/api/v0/crops/{shortName}", crop.getShortName())
.contentType(MediaType.APPLICATION_JSON))
.contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$.id", is(notNullValue())))
.andExpect(jsonPath("$.version", is(0)))
.andExpect(jsonPath("$.shortName", is("maize")))
......@@ -184,9 +184,9 @@ public class CropsControllerTest extends AbstractRestTest {
createCropTest();
mockMvc.perform(delete("/api/v0/crops/{shortName}", "rice")
.contentType(MediaType.APPLICATION_JSON))
.contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$.id", is(nullValue())))
.andExpect(jsonPath("$.version", is(0)))
.andExpect(jsonPath("$.shortName", is("rice")))
......@@ -205,9 +205,9 @@ public class CropsControllerTest extends AbstractRestTest {
LOG.info("Start test-method getCropDescriptorsTest");
mockMvc.perform(get("/api/v0/crops/{shortName}/descriptors", crop.getShortName())
.contentType(MediaType.APPLICATION_JSON))
.contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$.content", hasSize(0)))
//.andExpect(jsonPath("$.lastPage", is(true)))
.andExpect(jsonPath("$.numberOfElements", is(0)))
......@@ -229,9 +229,9 @@ public class CropsControllerTest extends AbstractRestTest {
LOG.info("Start test-method getCropRulesTest");
mockMvc.perform(get("/api/v0/crops/{shortName}/rules", crop.getShortName())
.contentType(MediaType.APPLICATION_JSON))
.contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$", hasSize(1)))
.andExpect(jsonPath("$[0].id", is(notNullValue())))
.andExpect(jsonPath("$[0].included", is(true)))
......@@ -261,10 +261,10 @@ public class CropsControllerTest extends AbstractRestTest {
cropRules.add(cropRule);
mockMvc.perform(put("/api/v0/crops/{shortName}/rules", crop.getShortName())
.contentType(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON_UTF8)
.content(objectMapper.writeValueAsString(cropRules)))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$", hasSize(1)))
.andExpect(jsonPath("$[0].id", is(notNullValue())))
.andExpect(jsonPath("$[0].included", is(true)))
......@@ -289,9 +289,9 @@ public class CropsControllerTest extends AbstractRestTest {
LOG.info("Start test-method getCropTaxaTest");
mockMvc.perform(get("/api/v0/crops/{shortName}/taxa", crop.getShortName())
.contentType(MediaType.APPLICATION_JSON))
.contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$.content", hasSize(0)))
// .andExpect(jsonPath("$.lastPage", is(true)))
.andExpect(jsonPath("$.numberOfElements", is(0)))
......@@ -316,9 +316,9 @@ public class CropsControllerTest extends AbstractRestTest {
JsonNode jsonNode = objectMapper.readTree(JSON_OK);
mockMvc.perform(post("/api/v0/crops/rebuild")
.contentType(MediaType.APPLICATION_JSON))
.contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().string(objectMapper.writeValueAsString(jsonNode)));
LOG.info("Test rebuildTest passed");
......@@ -334,9 +334,9 @@ public class CropsControllerTest extends AbstractRestTest {
JsonNode jsonNode = objectMapper.readTree(JSON_OK);
mockMvc.perform(post("/api/v0/crops/{shortName}/rebuild", crop.getShortName())
.contentType(MediaType.APPLICATION_JSON))
.contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().string(objectMapper.writeValueAsString(jsonNode)));
LOG.info("Test rebuildCropTest passed");
......
......@@ -63,7 +63,7 @@ public class LookupControllerTest extends AbstractRestTest {
mockMvc.perform(get("/api/v0/lookup/orgCty")
.contentType(MediaType.APPLICATION_JSON).param("lang", ""))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().string(objectmapper.writeValueAsString(orgCty)));
LOG.info("Test getTest is passed");
......
......@@ -86,10 +86,10 @@ public class OrganizationControllerTest extends AbstractRestTest {
ObjectMapper objectMapper = new ObjectMapper();
mockMvc.perform(get("/api/v0/org")
.contentType(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON_UTF8)
.param("page", "1"))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().string(objectMapper.writeValueAsString(organizationService.list(new PageRequest(0, 10)).getContent())));
LOG.info("Test listOrganizationsTest is passed");
......@@ -103,10 +103,10 @@ public class OrganizationControllerTest extends AbstractRestTest {
organization.setTitle("newTitle");
mockMvc.perform(post("/api/v0/org")
.contentType(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON_UTF8)
.content(objectMapper.writeValueAsString(organization)))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().string(objectMapper.writeValueAsString(organization)));
LOG.info("Test updateOrganizationTest is passed");
......@@ -119,7 +119,7 @@ public class OrganizationControllerTest extends AbstractRestTest {
ObjectMapper objectMapper = new ObjectMapper();
mockMvc.perform(get("/api/v0/org/{shortName}", organization.getSlug())
.contentType(MediaType.APPLICATION_JSON))
.contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(status().isOk())
.andExpect(content().string(objectMapper.writeValueAsString(organization)));
......@@ -131,7 +131,7 @@ public class OrganizationControllerTest extends AbstractRestTest {
LOG.info("Start test-method getBlurpTest");
mockMvc.perform(get("/api/v0/org/{shortName}/blurp/{language}", organization.getSlug(), article.getLang())
.contentType(MediaType.APPLICATION_JSON))
.contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(status().isOk())
.andExpect(content().string(article.getBody()));
......@@ -148,10 +148,10 @@ public class OrganizationControllerTest extends AbstractRestTest {
organizationBlurpJson.locale = "en";
mockMvc.perform(put("/api/v0/org/{shortName}/blurp", organization.getSlug())
.contentType(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON_UTF8)
.content(objectMapper.writeValueAsString(organizationBlurpJson)))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().string(objectMapper.writeValueAsString(organizationService.updateAbout(organization, organizationBlurpJson.blurp, organizationBlurpJson.summary, organizationBlurpJson.getLocale()))));
LOG.info("test updateBlurpTest is passed");
......@@ -165,9 +165,9 @@ public class OrganizationControllerTest extends AbstractRestTest {
organization.setId(null);
mockMvc.perform(delete("/api/v0/org/{shortName}", organization.getSlug())
.contentType(MediaType.APPLICATION_JSON))
.contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().string(objectMapper.writeValueAsString(organization)));
LOG.info("test deleteOrganizationTest is passed");
......@@ -180,9 +180,9 @@ public class OrganizationControllerTest extends AbstractRestTest {
ObjectMapper objectMapper = new ObjectMapper();
mockMvc.perform(get("/api/v0/org/{shortName}/institutes", organization.getSlug())
.contentType(MediaType.APPLICATION_JSON))
.contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().string(objectMapper.writeValueAsString(organizationService.getMembers(organizationService.getOrganization(organization.getSlug())))));
LOG.info("test getOrganizationMembersTest is passed");
......@@ -214,10 +214,10 @@ public class OrganizationControllerTest extends AbstractRestTest {
instituteList.add(secondFaoInstitute.getCode());
mockMvc.perform(post("/api/v0/org/{slug}/add-institutes", organization.getSlug())
.contentType(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON_UTF8)
.content(objectMapper.writeValueAsString(instituteList)))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().string(objectMapper.writeValueAsString(true)));
LOG.info("test addOrganizationInstitutesTest is passed");
......@@ -249,10 +249,10 @@ public class OrganizationControllerTest extends AbstractRestTest {
instituteList.add(thirdFaoInstitute.getCode());
mockMvc.perform(post("/api/v0/org/{slug}/set-institutes", organization.getSlug())
.contentType(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON_UTF8)
.content(objectMapper.writeValueAsString(instituteList)))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().string(objectMapper.writeValueAsString(true)));
LOG.info("test setOrganizationInstitutesTest is passed");
......
......@@ -171,7 +171,7 @@ public class TokenControllerTest extends AbstractRestTest {
mockMvc.perform(get("/api/v0/clients/{client}/list/tokens", user.getEmail())
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$", hasSize(1)))
.andExpect(jsonPath("$[0].access_token", not(isEmptyString())))
.andExpect(jsonPath("$[0].token_type", is(accessToken.getTokenType())))
......@@ -220,7 +220,7 @@ public class TokenControllerTest extends AbstractRestTest {
mockMvc.perform(delete("/api/v0/clients/{client}/tokens/revoke/{token}", user.getEmail(), oAuth2AccessTokenForTest)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().string(objectMapper.writeValueAsString(simpleMessage)));
LOG.info("Test revokeClientTokenTest passed");
......
......@@ -156,7 +156,7 @@ public class ApiImagesDocsTest extends AbstractRestTest {
RepositoryImage ri = objectMapper.readValue(r.getResponse().getContentAsString(), RepositoryImage.class);
LOG.info(ri);
sb.append(ri.getUuid());
}).andExpect(jsonPath("$.id", greaterThan(0))).andExpect(jsonPath("$.path", is("/accessions/" + TEST_INSTCODE + "/acn/" + ACCENUMB + "/")))
}).andExpect(jsonPath("$.id", greaterThan(0))).andExpect(jsonPath("$.path", is("/accessions/" + TEST_INSTCODE + "/acn/" + ACCENUMB)))
.andExpect(jsonPath("$.originalFilename", is(image1.getOriginalFilename()))).andExpect(jsonPath("$.contentType", is("image/jpeg")))
.andDo(document("img-instgallery-put",
pathParameters(parameterWithName("instCode").description("Institute WIEWS code (e.g. NGA039)"),
......@@ -168,6 +168,7 @@ public class ApiImagesDocsTest extends AbstractRestTest {
fieldWithPath("extension").description("Image extension derived from original filename (e.g. '.jpg')"),
fieldWithPath("contentType").description("The content type of the image (autodetected when possible)"), fieldWithPath("format").description("Image format"),
fieldWithPath("path").description("Location (directory) of the image in the Genesys repository"),
fieldWithPath("size").description("Image size in bytes"),
fieldWithPath("filename").description("The new generated filename of the image"),
fieldWithPath("url").description("The relative URL to the image in Genesys repository [path+filename]"),
fieldWithPath("sha1Sum").description("SHA1 hash of the image bytes"), fieldWithPath("md5Sum").description("MD5 hash of the image bytes"),
......@@ -177,8 +178,9 @@ public class ApiImagesDocsTest extends AbstractRestTest {
fieldWithPath("id").ignored(), fieldWithPath("title").ignored(), fieldWithPath("subject").ignored(), fieldWithPath("description").ignored(),
fieldWithPath("creator").ignored(), fieldWithPath("created").ignored(), fieldWithPath("rightsHolder").ignored(), fieldWithPath("accessRights").ignored(),
fieldWithPath("license").ignored(), fieldWithPath("extent").ignored(), fieldWithPath("bibliographicCitation").ignored(), fieldWithPath("createdDate").ignored(),
fieldWithPath("lastModifiedDate").ignored(), fieldWithPath("originalUrl").ignored(), fieldWithPath("dateRetrieved").ignored(), fieldWithPath("dateSubmitted").ignored(),
fieldWithPath("modified").ignored())));
fieldWithPath("lastModifiedDate").ignored(), fieldWithPath("lastModifiedBy").ignored(), fieldWithPath("originalUrl").ignored(), fieldWithPath("dateRetrieved").ignored(), fieldWithPath("dateSubmitted").ignored(),
fieldWithPath("modified").ignored(), fieldWithPath("version").ignored(), fieldWithPath("active").ignored(), fieldWithPath("createdBy").ignored(),
fieldWithPath("thumbnailPath").ignored(), fieldWithPath("storagePath").ignored(), fieldWithPath("storageFullPath").ignored())));
UUID uuid = UUID.fromString(sb.toString());
LOG.info("UUID=" + uuid);
......@@ -213,7 +215,9 @@ public class ApiImagesDocsTest extends AbstractRestTest {
"Access rights provides information about restrictions to view, search or use a resource based on attributes of the resource itself or the category of user."),
fieldWithPath("license").description("Legal document giving official permission to do something with the resource. E.g. http://www.gnu.org/licenses/gpl.html"),
fieldWithPath("extent").description("Size (e.g. bytes, pages, inches, etc.) or duration (e.g. hours, minutes, days, etc.) of a resource"),
fieldWithPath("bibliographicCitation").description("Formal bibliographic citation for the resource")),
fieldWithPath("bibliographicCitation").description("Formal bibliographic citation for the resource"),
// ignored
fieldWithPath("active").ignored(), fieldWithPath("id").ignored(), fieldWithPath("thumbnailPath").ignored(), fieldWithPath("url").ignored(), fieldWithPath("storageFullPath").ignored()),
responseFields(fieldWithPath("uuid").ignored(), fieldWithPath("originalFilename").description("The original filename that you have provided"),
fieldWithPath("extension").ignored(), fieldWithPath("contentType").ignored(), fieldWithPath("path").ignored(), fieldWithPath("filename").ignored(),
fieldWithPath("url").ignored(), fieldWithPath("sha1Sum").ignored(), fieldWithPath("md5Sum").ignored(),
......@@ -235,9 +239,11 @@ public class ApiImagesDocsTest extends AbstractRestTest {
fieldWithPath("license").description("Legal document giving official permission to do something with the resource. E.g. http://www.gnu.org/licenses/gpl.html"),
fieldWithPath("extent").description("Size (e.g. bytes, pages, inches, etc.) or duration (e.g. hours, minutes, days, etc.) of a resource"),
fieldWithPath("bibliographicCitation").description("Formal bibliographic citation for the resource"),
fieldWithPath("size").description("Image size in bytes"),
// ignored
fieldWithPath("createdDate").ignored(), fieldWithPath("lastModifiedDate").ignored(), fieldWithPath("originalUrl").ignored(), fieldWithPath("dateRetrieved").ignored(),
fieldWithPath("dateSubmitted").ignored(), fieldWithPath("modified").ignored())));
fieldWithPath("id").ignored(), fieldWithPath("version").ignored(),
fieldWithPath("createdDate").ignored(), fieldWithPath("createdBy").ignored(), fieldWithPath("lastModifiedDate").ignored(), fieldWithPath("lastModifiedBy").ignored(), fieldWithPath("originalUrl").ignored(), fieldWithPath("dateRetrieved").ignored(),
fieldWithPath("dateSubmitted").ignored(), fieldWithPath("modified").ignored(), fieldWithPath("active").ignored(), fieldWithPath("thumbnailPath").ignored(), fieldWithPath("url").ignored(), fieldWithPath("storageFullPath").ignored(), fieldWithPath("storagePath").ignored())));
mockMvc.perform(get("/api/v0/img/{instCode}/acn/{acceNumb}/{uuid}/_metadata", TEST_INSTCODE, ACCENUMB, uuid)).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andDo(r -> {
......@@ -257,12 +263,13 @@ public class ApiImagesDocsTest extends AbstractRestTest {
fieldWithPath("sha1Sum").description("SHA1 hash of the image bytes"), fieldWithPath("md5Sum").description("MD5 hash of the image bytes"),
fieldWithPath("width").description("Image width in pixels (autodetected)"), fieldWithPath("height").description("Image height in pixels (autodetected)"),
fieldWithPath("orientation").description("LANDSCAPE or PORTRAIT orientation of the image (autodetected)"),
fieldWithPath("size").description("Image size in bytes"),
// Ignored stuff
fieldWithPath("id").ignored(), fieldWithPath("title").ignored(), fieldWithPath("subject").ignored(), fieldWithPath("description").ignored(),
fieldWithPath("id").ignored(), fieldWithPath("version").ignored(), fieldWithPath("title").ignored(), fieldWithPath("subject").ignored(), fieldWithPath("description").ignored(),
fieldWithPath("creator").ignored(), fieldWithPath("created").ignored(), fieldWithPath("rightsHolder").ignored(), fieldWithPath("accessRights").ignored(),
fieldWithPath("license").ignored(), fieldWithPath("extent").ignored(), fieldWithPath("bibliographicCitation").ignored(), fieldWithPath("createdDate").ignored(),
fieldWithPath("lastModifiedDate").ignored(), fieldWithPath("originalUrl").ignored(), fieldWithPath("dateRetrieved").ignored(), fieldWithPath("dateSubmitted").ignored(),
fieldWithPath("modified").ignored())));
fieldWithPath("license").ignored(), fieldWithPath("extent").ignored(), fieldWithPath("bibliographicCitation").ignored(), fieldWithPath("createdDate").ignored(), fieldWithPath("createdBy").ignored(),
fieldWithPath("lastModifiedDate").ignored(), fieldWithPath("lastModifiedBy").ignored(), fieldWithPath("originalUrl").ignored(), fieldWithPath("dateRetrieved").ignored(), fieldWithPath("dateSubmitted").ignored(),
fieldWithPath("modified").ignored(), fieldWithPath("active").ignored(), fieldWithPath("id").ignored(), fieldWithPath("thumbnailPath").ignored(), fieldWithPath("url").ignored(), fieldWithPath("storagePath").ignored(), fieldWithPath("storageFullPath").ignored())));
mockMvc.perform(get("/api/v0/img/{instCode}/acn/{acceNumb}/_list", TEST_INSTCODE, ACCENUMB)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andDo(r -> {
LOG.info("Listing image UUIDs: " + r.getResponse().getContentAsString());
......
......@@ -15,9 +15,12 @@
**/
package org.genesys2.tests.unit;
import java.util.Set;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.velocity.app.VelocityEngine;
import org.elasticsearch.common.collect.Sets;
import org.genesys.blocks.persistence.ClassPKRepository;
import org.genesys.blocks.security.service.CustomAclService;
import org.genesys.blocks.security.service.PasswordPolicy;
......@@ -47,6 +50,7 @@ import org.genesys2.server.service.ElasticSearchManagementService;
import org.genesys2.server.service.ElasticService;
import org.genesys2.server.service.GenesysFilterService;
import org.genesys2.server.service.GenesysService;
import org.genesys2.server.service.GeoRegionService;
import org.genesys2.server.service.GeoService;
import org.genesys2.server.service.HtmlSanitizer;
import org.genesys2.server.service.InstituteService;
......@@ -69,6 +73,7 @@ import org.genesys2.server.service.impl.ElasticsearchSearchServiceImpl;
import org.genesys2.server.service.impl.FilterHandler;
import org.genesys2.server.service.impl.GenesysFilterServiceImpl;
import org.genesys2.server.service.impl.GenesysServiceImpl;
import org.genesys2.server.service.impl.GeoRegionServiceImpl;
import org.genesys2.server.service.impl.GeoServiceImpl;
import org.genesys2.server.service.impl.InstituteServiceImpl;
import org.genesys2.server.service.impl.MappingServiceImpl;
......@@ -80,6 +85,7 @@ import org.genesys2.server.service.impl.TokenVerificationServiceImpl;
import org.genesys2.server.service.impl.TraitServiceImpl;
import org.genesys2.server.service.impl.UserServiceImpl;
import org.genesys2.server.service.worker.ElasticUpdater;
import org.genesys2.server.service.worker.GeoRegionDataCLDR;
import org.genesys2.server.test.PropertyPlacholderInitializer;
import org.genesys2.tests.BaseSpringTest;
import org.junit.runner.RunWith;
......@@ -240,6 +246,16 @@ public abstract class AbstractServicesTest extends BaseSpringTest {
public GeoService geoService() {
return new GeoServiceImpl();
}
@Bean
public GeoRegionService geoRegionService() {
return new GeoRegionServiceImpl();
}
@Bean
public GeoRegionDataCLDR geoRegionDataCldr() {
return new GeoRegionDataCLDR();
}
@Bean
public PasswordPolicy passwordPolicy() {
......@@ -270,6 +286,12 @@ public abstract class AbstractServicesTest extends BaseSpringTest {
public ObjectMapper objectMapper() {
return new ObjectMapper();
}
@Bean
public static Set<String> supportedLocales() {
final Set<String> supportedLocales = Sets.newHashSet("en", "es", "de", "fr", "fa", "ar", "ru", "zh", "pt");
return supportedLocales;
}
}
@Autowired
......
......@@ -177,7 +177,7 @@ public class UserServiceTest extends AbstractServicesTest {
LOG.info("Start test-method createUserTest");
User newUser = userService.createUser(email, initialPassword, fullName, AccountType.LOCAL);
User newUser = userService.createUser(email, fullName, initialPassword, AccountType.LOCAL);
assertNotNull("User is ull", newUser);
......@@ -563,7 +563,7 @@ public class UserServiceTest extends AbstractServicesTest {
public void changePasswordForUserWithPasswordTypeTest() throws UserException {
LOG.info("Start test-method changePasswordForUserWithPasswordTypeTest");
User createdUser = userService.createUser(email, initialPassword, fullName, AccountType.LOCAL);
User createdUser = userService.createUser(email, fullName, initialPassword, AccountType.LOCAL);
String newPassword = "New password1!";
try {
......@@ -592,8 +592,8 @@ public class UserServiceTest extends AbstractServicesTest {
String newPassword = "New password";
try {
userService.changePassword(createdUser, newPassword);
fail("Expected exception to be thrown");
} catch (PasswordPolicyException e) {
fail(e.getMessage());
}
try {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment