-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make fields accessible for refactoring, added draft implementation for
zoho data generator #EA-3641
- Loading branch information
GordeaS
authored and
GordeaS
committed
Jan 31, 2024
1 parent
c3561f9
commit fa82714
Showing
14 changed files
with
96 additions
and
15 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
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
59 changes: 59 additions & 0 deletions
59
...tion-test/java/eu/europeana/entitymanagement/zoho/organization/ZohoTestDataGenerator.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,59 @@ | ||
package eu.europeana.entitymanagement.zoho.organization; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
import java.util.Optional; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.context.annotation.Bean; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.zoho.crm.api.record.Record; | ||
import eu.europeana.entitymanagement.common.config.EntityManagementConfiguration; | ||
import eu.europeana.entitymanagement.common.vocabulary.AppConfigConstants; | ||
import eu.europeana.entitymanagement.config.SerializationConfig; | ||
import eu.europeana.entitymanagement.testutils.IntegrationTestUtils; | ||
import eu.europeana.entitymanagement.testutils.ZohoRecordTestDeserializer; | ||
|
||
/** JUnit test to check if DataSources are properly deserialized from XML */ | ||
@SpringBootTest(classes = {SerializationConfig.class, ZohoConfiguration.class, EntityManagementConfiguration.class}) | ||
public class ZohoTestDataGenerator { | ||
|
||
@Autowired | ||
@Qualifier(AppConfigConstants.BEAN_JSON_MAPPER) | ||
private ObjectMapper jsonMapper; | ||
|
||
@Autowired | ||
ZohoConfiguration zohoConfiguration; | ||
EntityManagementConfiguration emConfig; | ||
|
||
@Bean | ||
ZohoDereferenceService getZohoDereferenceService() { | ||
return new ZohoDereferenceService(zohoConfiguration, emConfig); | ||
} | ||
|
||
// @Test | ||
//manually enable the test when data needs to be generated | ||
public void generateBNFJson() throws Exception { | ||
//get original zoho record | ||
Optional<Record> zohoOrganization = | ||
zohoConfiguration.getZohoAccessClient().getZohoRecordOrganizationById(IntegrationTestUtils.ORGANIZATION_BNF_URI_ZOHO); | ||
String zohoRecord = getZohoDereferenceService().serialize(zohoOrganization.get()); | ||
//if you need to see original enable : System.out.println(zohoRecord); | ||
System.out.println(zohoRecord); | ||
|
||
//deserialize data with the test deserializer | ||
ZohoRecordTestDeserializer zohoRecordDeserializer = new ZohoRecordTestDeserializer(); | ||
//TODO: many fields are missing or need to be renamed in the deserializer, need to include all fields from ZohoMaping except for the sensitive ones (like email addresses) | ||
Record zohoTestRecord = zohoRecordDeserializer.deserialize(jsonMapper.getFactory().createParser(zohoRecord), jsonMapper.getDeserializationContext()); | ||
|
||
//serialize test data | ||
String zohoTestRecordJson = getZohoDereferenceService().serialize(zohoTestRecord); | ||
System.out.println(zohoTestRecordJson); | ||
|
||
Record zohoTestRecordFiltered = zohoRecordDeserializer.deserialize(jsonMapper.getFactory().createParser(zohoTestRecordJson), jsonMapper.getDeserializationContext()); | ||
assertNotNull(zohoTestRecordFiltered.getId()); | ||
assertNotNull(zohoTestRecordFiltered.getKeyValue("Account_Name")); | ||
|
||
} | ||
} |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/SDKLogs.log* | ||
**/log4j2.xml | ||
/sdk_tokens.txt |
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
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