/*
 * Copyright 2011-2016 B2i Healthcare Pte Ltd, http://b2i.sg
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.b2international.snowowl.snomed.datastore.index.entry;

import java.util.Collection;
import java.util.Collections;

import org.junit.Test;

import com.b2international.collections.PrimitiveCollectionModule;
import com.b2international.index.revision.BaseRevisionIndexTest;
import com.b2international.index.revision.RevisionBranch;
import com.b2international.snowowl.snomed.SnomedConstants.Concepts;
import com.b2international.snowowl.snomed.core.domain.CharacteristicType;
import com.b2international.snowowl.snomed.core.domain.RelationshipModifier;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * @since 4.7
 */
public class SnomedRelationshipIndexEntrySerializationTest extends BaseRevisionIndexTest {

	@Override
	protected Collection<Class<?>> getTypes() {
		return Collections.<Class<?>>singleton(SnomedRelationshipIndexEntry.class);
	}
	
	@Override
	protected void configureMapper(ObjectMapper mapper) {
		mapper.registerModule(new PrimitiveCollectionModule());
	}
	
	@Test
	public void indexRelationship() throws Exception {
		final SnomedRelationshipIndexEntry relationship = SnomedRelationshipIndexEntry.builder()
				.id("1")
				.moduleId(Concepts.MODULE_ROOT)
				.sourceId(Concepts.ROOT_CONCEPT)
				.destinationId(Concepts.ROOT_CONCEPT)
				.typeId(Concepts.IS_A)
				.characteristicTypeId(CharacteristicType.STATED_RELATIONSHIP.getConceptId())
				.modifierId(RelationshipModifier.EXISTENTIAL.getConceptId())
				.build();
		indexRevision(RevisionBranch.MAIN_PATH, STORAGE_KEY1, relationship);
		assertDocEquals(relationship, getRevision(RevisionBranch.MAIN_PATH, SnomedRelationshipIndexEntry.class, STORAGE_KEY1));
	}
	
}

@@ -746,16 +746,39 @@
 ections;
+%0Aimport java.util.Date;
 %0A%0Aimport
@@ -1800,16 +1800,95 @@
 id(%221%22)%0A
+%09%09%09%09.active(true)%0A%09%09%09%09.released(true)%0A%09%09%09%09.effectiveTime(new Date().getTime())%0A
 %09%09%09%09.mod
@@ -2163,24 +2163,87 @@
 onceptId())%0A
+%09%09%09%09.destinationNegated(true)%0A%09%09%09%09.group(1)%0A%09%09%09%09.unionGroup(1)%0A
 %09%09%09%09.build()

add remaining props to indexRelationship test