Notifications
Clear all

[Solved] Testing UI upload inbound interfaces

5 Posts
4 Users
0 Reactions
7,559 Views
0
Topic starter

Need a way to test UI Upload inbound interfaces. The UI upload interfaces is a special version of inbound interface that uses User context to pre-populate some field values ( eg: creation org) 

This is what I tried. 

PlatformUserContext productionManagerContext = ucs.createContext(vc.user.sysId, vc.role.sysId)

csvLoader = new CsvLoader(productionManagerContext);

def results = csvLoader.load("MFG.Production_Order_Upload", "5.0", csvRows)

However , inside the transformer, only VC Admin Context is availble. 

Is there any easy way to mimic the UI upload  in server tests so that  ?

 

This topic was modified 3 years ago by Prasanth Mallaya
Ravi Abram 2021-10-14 18:20:39

@pmallaya @gmerrill,

Can you give user-role access to an upload/action framework, but process it behind the scenes as another role (like VC Admin above which may have been reserved to be the only allowed role to process inbound B2B feeds)

I know this may add a security challenge, but could we support VC level properties for this, e.g. is Demo env. etc.?

2 Answers
0

Can you see if setUseProcessingContextForDequeue(true) helps?

0
Topic starter

I extended CsvLoader in my module so that I can setUseProcessingContextForDequeue(true) 

Here's the code I used to extend the CsvLoader

 

import java.io.*;
import java.util.List;
import java.util.Map;

import com.onenetwork.platform.common.usercontext.PlatformUserContext;
import com.transcendsys.platform.base.context.DvceContext;
import com.transcendsys.platform.server.csv.UploadInboundInterfaceCsvFiles;
import com.transcendsys.platform.server.csv.UploadInboundInterfaceCsvFiles.Mode;

public class CsvLoader extends com.transcendsys.platform.server.csv.CsvLoader {
boolean useProcessingContextForDequeue = false;

public boolean isUseProcessingContextForDequeue() {
return useProcessingContextForDequeue;
}

/**
* @param useProcessingContextForDequeue
* the useProcessingContextForDequeue to set
*/
public void setUseProcessingContextForDequeue(boolean useProcessingContextForDequeue) {
this.useProcessingContextForDequeue = useProcessingContextForDequeue;
}

CsvLoader(PlatformUserContext context, boolean useProcessingContextForDequeue) {
super(context);
this.useProcessingContextForDequeue = useProcessingContextForDequeue;
}

public List<Map<String, String>> load(String interfaceName, String interfaceVersion, List<Map<String, String>> values, boolean useQueue) {
try {
String csv = valMapListToString(interfaceName, interfaceVersion, values);
File csvFile = File.createTempFile("" + System.currentTimeMillis(), ".csv");
Writer writer = null;
try {
writer = new FileWriter(csvFile);
writer.write(csv);
writer.flush();
Writer temp = writer;
temp.close();
} finally {
closeWithWarning(writer);
}
UploadInboundInterfaceCsvFiles uploadFiles = new UploadInboundInterfaceCsvFiles((DvceContext) getContext(), useQueue ? Mode.MESSAGE : Mode.SIMPLE, getQueueRef());
uploadFiles.setUseProcessingContextForDequeue(useProcessingContextForDequeue);
String resultStr = uploadFiles.process(interfaceName, interfaceVersion, csvFile, null, null);
return parseResultString(interfaceName, interfaceVersion, resultStr);

}catch(Exception e) {
return null;
}
}

/**
* TODO complete method documentation
*
* @param writer
*/
private void closeWithWarning(Writer c) {
if (c != null) {
try {
c.close();
} catch (IOException e) {
System.out.println("Caught exception during close(): " + e);
}
}
}
}

Piyush Patil 2021-10-18 06:04:41

@pmallaya
I have modified CsvLoader in Neo 3.5 for supporting useProcessingContextForDequeue

Prasanth Mallaya Topic starter 2021-10-20 17:57:15

Thanks Piyush.