1
|
package eu.dnetlib.msro.openaireplus.workflows.nodes.claims;
|
2
|
|
3
|
import com.google.protobuf.InvalidProtocolBufferException;
|
4
|
import eu.dnetlib.data.proto.OafProtos.Oaf;
|
5
|
import eu.dnetlib.msro.rmi.MSROException;
|
6
|
import org.junit.Test;
|
7
|
import org.postgresql.util.Base64;
|
8
|
|
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
|
public void testGetValue() throws MSROException, InvalidProtocolBufferException {
|
20
|
|
21
|
String sourceId = "40|corda_______::9f752db0b5ec9ca23673ca7f4cb0808e";
|
22
|
String semantics = "resultProject_outcome_produces";
|
23
|
String targetId = "50|userclaim___::6a8f649d968e734a6733c23a351c1859";
|
24
|
System.out.println(getValue(sourceId, semantics, targetId));
|
25
|
}
|
26
|
|
27
|
@Test(expected = MSROException.class)
|
28
|
public void testGetValueErrSem() throws MSROException, InvalidProtocolBufferException {
|
29
|
|
30
|
String sourceId = "40|corda_______::9f752db0b5ec9ca23673ca7f4cb0808e";
|
31
|
String semantics = "produces";
|
32
|
String targetId = "50|userclaim___::6a8f649d968e734a6733c23a351c1859";
|
33
|
getValue(sourceId, semantics, targetId);
|
34
|
}
|
35
|
|
36
|
private String getValue(final String rowKey, final String semantics, final String targetId) throws MSROException, InvalidProtocolBufferException {
|
37
|
long time = System.currentTimeMillis();
|
38
|
//final String sourceId, final String semantics, final String targetId, final long timestamp
|
39
|
String res = applyClaims.getValue(rowKey, semantics, targetId, time);
|
40
|
Oaf.Builder builder = Oaf.newBuilder().mergeFrom(Base64.decode(res));
|
41
|
return builder.build().toString();
|
42
|
}
|
43
|
}
|