Project

General

Profile

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 ApplyClaimUpdatesJobNodeTest {
15

    
16
	private ApplyClaimUpdatesJobNode applyClaims = new ApplyClaimUpdatesJobNode();
17

    
18

    
19
	@Test
20
	public void testGetValueEGI() throws MSROException, InvalidProtocolBufferException {
21
		String context = "egi";
22
		String rowkey = "50|userclaim___::6a8f649d968e734a6733c23a351c1859";
23
		System.out.println(getValue(context, rowkey));
24
	}
25

    
26
	@Test
27
	public void testGetValueEGILongId() throws MSROException, InvalidProtocolBufferException {
28
		String context = "egi::classification::natsc::earths::other";
29
		String rowkey = "50|userclaim___::6a8f649d968e734a6733c23a351c1859";
30
		System.out.println(getValue(context, rowkey));
31
	}
32

    
33
	private String getValue(final String context, final String rowkey) throws MSROException, InvalidProtocolBufferException {
34
		String semantics = "relatedTo";
35
		long time = System.currentTimeMillis();
36
		//final String sourceId, final String semantics, final String targetId, final long timestamp
37
		String res = applyClaims.getValue(context, semantics, rowkey, time);
38
		Oaf.Builder builder = Oaf.newBuilder().mergeFrom(Base64.decode(res));
39
		return builder.build().toString();
40
	}
41
}
(2-2/2)