Project

General

Profile

« Previous | Next » 

Revision 47712

Fixed semantics and added test

View differences:

modules/dnet-openaireplus-workflows/trunk/src/test/java/leu/dnetlib/msro/openaireplus/workflows/nodes/claims/ApplyClaimRelsJobNodeTest.java
1
package leu.dnetlib.msro.openaireplus.workflows.nodes.claims;
2

  
3
import eu.dnetlib.msro.openaireplus.workflows.nodes.claims.ApplyClaimRelsJobNode;
4
import eu.dnetlib.msro.rmi.MSROException;
5
import org.junit.Test;
6

  
7
/**
8
 * Created by Alessia Bardi on 26/06/2017.
9
 *
10
 * @author Alessia Bardi
11
 */
12
public class ApplyClaimRelsJobNodeTest {
13

  
14
	private ApplyClaimRelsJobNode applyClaims = new ApplyClaimRelsJobNode();
15

  
16

  
17
	@Test
18
	public void testGetValue() throws MSROException {
19

  
20
		String sourceId = "40|corda_______::9f752db0b5ec9ca23673ca7f4cb0808e";
21
		String semantics = "resultProject_outcome_produces";
22
		String targetId = "50|userclaim___::6a8f649d968e734a6733c23a351c1859";
23
		long time = System.currentTimeMillis();
24
		//final String sourceId, final String semantics, final String targetId, final long timestamp
25
		String res = applyClaims.getValue(sourceId, semantics, targetId, time);
26
		System.out.println(res);
27
	}
28

  
29
	@Test(expected = MSROException.class)
30
	public void testGetValueErrSem() throws MSROException {
31

  
32
		String sourceId = "40|corda_______::9f752db0b5ec9ca23673ca7f4cb0808e";
33
		String semantics = "produces";
34
		String targetId = "50|userclaim___::6a8f649d968e734a6733c23a351c1859";
35
		long time = System.currentTimeMillis();
36
		//final String sourceId, final String semantics, final String targetId, final long timestamp
37
		String res = applyClaims.getValue(sourceId, semantics, targetId, time);
38
		System.out.println(res);
39
	}
40
}
modules/dnet-openaireplus-workflows/trunk/src/main/java/eu/dnetlib/msro/openaireplus/workflows/nodes/claims/ApplyClaimRelsJobNode.java
110 110
	}
111 111

  
112 112

  
113
	private String getValue(final String sourceId, final String semantics, final String targetId, final long timestamp) throws MSROException{
113
	public String getValue(final String sourceId, final String semantics, final String targetId, final long timestamp) throws MSROException{
114 114
		log.debug(StringUtils.format("%s -- %s -- %s", sourceId, semantics, targetId));
115 115
		String[] relInfo = semantics.split(SEPARATOR);
116
		if(relInfo.length < 3){
117
			throw new MSROException("Semantics "+semantics+" not supported: must be splittable in 3 by '_'");
118
		}
116 119
		Qualifier.Builder semanticsBuilder = Qualifier.newBuilder().setClassid(relInfo[2]).setClassname(relInfo[2]);
117 120

  
118 121
		Oaf.Builder builder = Oaf.newBuilder().setKind(Kind.relation).setLastupdatetimestamp(timestamp);
......
144 147
											.build()
145 148
							))));
146 149
			break;
147
		case "resultResult_publicationDataset_isRelatedTo":
150
		case "resultResult":
148 151
			relBuilder.setResultResult(ResultResult.newBuilder()
149 152
					.setPublicationDataset(PublicationDataset.newBuilder().setRelMetadata(
150 153
							RelMetadata.newBuilder().setSemantics(

Also available in: Unified diff