1 |
48027
|
alessia.ba
|
package eu.dnetlib.msro.openaireplus.workflows.nodes.claims;
|
2 |
47712
|
alessia.ba
|
|
3 |
48010
|
alessia.ba
|
import com.google.protobuf.InvalidProtocolBufferException;
|
4 |
|
|
import eu.dnetlib.data.proto.OafProtos.Oaf;
|
5 |
47712
|
alessia.ba
|
import eu.dnetlib.msro.rmi.MSROException;
|
6 |
|
|
import org.junit.Test;
|
7 |
48010
|
alessia.ba
|
import org.postgresql.util.Base64;
|
8 |
47712
|
alessia.ba
|
|
9 |
|
|
/**
|
10 |
|
|
* Created by Alessia Bardi on 26/06/2017.
|
11 |
|
|
*
|
12 |
|
|
* @author Alessia Bardi
|
13 |
|
|
*/
|
14 |
|
|
public class ApplyClaimRelsJobNodeTest {
|
15 |
|
|
|
16 |
|
|
private ApplyClaimRelsJobNode applyClaims = new ApplyClaimRelsJobNode();
|
17 |
|
|
|
18 |
|
|
@Test
|
19 |
48010
|
alessia.ba
|
public void testGetValue() throws MSROException, InvalidProtocolBufferException {
|
20 |
47712
|
alessia.ba
|
|
21 |
|
|
String sourceId = "40|corda_______::9f752db0b5ec9ca23673ca7f4cb0808e";
|
22 |
|
|
String semantics = "resultProject_outcome_produces";
|
23 |
|
|
String targetId = "50|userclaim___::6a8f649d968e734a6733c23a351c1859";
|
24 |
48027
|
alessia.ba
|
System.out.println(getValue(sourceId, semantics, targetId));
|
25 |
47712
|
alessia.ba
|
}
|
26 |
|
|
|
27 |
|
|
@Test(expected = MSROException.class)
|
28 |
48027
|
alessia.ba
|
public void testGetValueErrSem() throws MSROException, InvalidProtocolBufferException {
|
29 |
47712
|
alessia.ba
|
|
30 |
|
|
String sourceId = "40|corda_______::9f752db0b5ec9ca23673ca7f4cb0808e";
|
31 |
|
|
String semantics = "produces";
|
32 |
|
|
String targetId = "50|userclaim___::6a8f649d968e734a6733c23a351c1859";
|
33 |
48027
|
alessia.ba
|
getValue(sourceId, semantics, targetId);
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
private String getValue(final String rowKey, final String semantics, final String targetId) throws MSROException, InvalidProtocolBufferException {
|
37 |
47712
|
alessia.ba
|
long time = System.currentTimeMillis();
|
38 |
|
|
//final String sourceId, final String semantics, final String targetId, final long timestamp
|
39 |
48027
|
alessia.ba
|
String res = applyClaims.getValue(rowKey, semantics, targetId, time);
|
40 |
|
|
Oaf.Builder builder = Oaf.newBuilder().mergeFrom(Base64.decode(res));
|
41 |
|
|
return builder.build().toString();
|
42 |
47712
|
alessia.ba
|
}
|
43 |
|
|
}
|