package eu.dnetlib.data.mapreduce.util;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import java.util.HashSet;
import java.util.Set;

import org.junit.Test;

import com.google.common.collect.Lists;

import eu.dnetlib.data.proto.RelTypeProtos.RelType;

public class OafRelDecoderTest {

	private Set<RelType> specialRelations = new HashSet<RelType>(Lists.newArrayList(RelType.dedupRel, RelType.similarityRel, RelType.similarRel));

	@Test
	public void test_dedupRel() {
		for (RelType relType : Lists.newArrayList(RelType.values())) {
			check(OafRelDecoder.decode(ProtoUtils.rel("A", "B", relType, false).build()));
		}
	}

	private void check(final OafRelDecoder decoder) {
		assertNotNull(decoder);

		if (specialRelations.contains(decoder.getRelType())) {
			assertNull(decoder.getRelMetadata());
		} else {
			assertNotNull(decoder.getRelMetadata());
		}
	}
}
