test
This commit is contained in:
parent
8ac49d1dab
commit
375d6c2513
|
@ -46,4 +46,9 @@ public class DbOrganization implements Serializable {
|
|||
this.orgId = orgId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("DbOrganization [community=%s, orgId=%s]", community, orgId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.community;
|
||||
package eu.dnetlib.openaire.community.importer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
import com.google.common.collect.Sets;
|
||||
|
||||
import eu.dnetlib.openaire.common.ISClient;
|
||||
import eu.dnetlib.openaire.community.db.CommunityImporterService;
|
||||
import eu.dnetlib.openaire.community.db.model.DbOrganization;
|
||||
import eu.dnetlib.openaire.exporter.exceptions.CommunityException;
|
||||
import eu.dnetlib.openaire.exporter.model.context.Context;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.openaire.community.db;
|
||||
package eu.dnetlib.openaire.community.importer;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
|
@ -25,6 +25,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
|||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import eu.dnetlib.openaire.community.db.CommunityService;
|
||||
import eu.dnetlib.openaire.community.db.model.DbOrganization;
|
||||
import eu.dnetlib.openaire.community.db.repository.DbOrganizationRepository;
|
||||
import eu.dnetlib.openaire.exporter.exceptions.CommunityException;
|
||||
|
@ -332,4 +333,20 @@ public class CommunityImporterService {
|
|||
.atZone(ZoneId.systemDefault())
|
||||
.toLocalDateTime();
|
||||
}
|
||||
|
||||
protected DbOrganizationRepository getDbOrganizationRepository() {
|
||||
return dbOrganizationRepository;
|
||||
}
|
||||
|
||||
protected void setDbOrganizationRepository(final DbOrganizationRepository dbOrganizationRepository) {
|
||||
this.dbOrganizationRepository = dbOrganizationRepository;
|
||||
}
|
||||
|
||||
protected CommunityService getService() {
|
||||
return service;
|
||||
}
|
||||
|
||||
protected void setService(final CommunityService service) {
|
||||
this.service = service;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package eu.dnetlib.openaire.community.importer;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import eu.dnetlib.openaire.community.db.CommunityService;
|
||||
import eu.dnetlib.openaire.community.db.model.DbOrganization;
|
||||
import eu.dnetlib.openaire.community.db.repository.DbOrganizationRepository;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class CommunityImporterServiceTest {
|
||||
|
||||
// Class under test
|
||||
private CommunityImporterService importer;
|
||||
|
||||
@Mock
|
||||
private DbOrganizationRepository dbOrganizationRepository;
|
||||
|
||||
@Mock
|
||||
private CommunityService service;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
importer = new CommunityImporterService();
|
||||
importer.setDbOrganizationRepository(dbOrganizationRepository);
|
||||
importer.setService(service);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testImportPropagationOrganizationsFromProfile() throws Exception {
|
||||
final String profile = IOUtils.toString(getClass().getResourceAsStream("old_provision_wf.xml"), StandardCharsets.UTF_8.toString());
|
||||
final List<DbOrganization> list = importer.importPropagationOrganizationsFromProfile(profile, true);
|
||||
list.forEach(System.out::println);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testImportCommunity() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue