<NME> CatalogFileToSolrFileConverterTest.java
<BEF> /*
 * Copyright 2015-2020 OpenCB
 *
 * 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,
import java.util.Arrays;

import static org.junit.Assert.assertEquals;

/**
 * Created by wasim on 13/08/18.
import org.junit.Test;
import org.opencb.biodata.models.clinical.interpretation.Software;
import org.opencb.opencga.catalog.stats.solr.FileSolrModel;
import org.opencb.opencga.catalog.stats.solr.converters.CatalogFileToSolrFileConverter;
import org.opencb.opencga.core.common.TimeUtils;
import org.opencb.opencga.core.models.file.File;
                "test/base", "convertorTest", new File.FileStatus("READY"), 1111L, 2);
        file.setUid(111).setSamples(Arrays.asList(new Sample().setId("1"), new Sample().setId("2")))
                .setExperiment(new Experiment().setName("Experiment")).setSoftware(new Software().setName("Software"));

        CatalogFileToSolrFileConverter converter = new CatalogFileToSolrFileConverter();
        FileSolrModel fileSolrModel = converter.convertToStorageType(file);

        assert (fileSolrModel.getUid() == file.getUid());
        assert (fileSolrModel.getName() == file.getName());

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

/**
 * Created by wasim on 13/08/18.
 */
public class CatalogFileToSolrFileConverterTest {

        assert (fileSolrModel.getExperiment() == file.getExperiment().getName());
        assert (fileSolrModel.getSamples() == file.getSamples().size());

    }

}
        assert (fileSolrModel.getType().equals(file.getType().name()));
        assert (fileSolrModel.getFormat().equals(file.getFormat().name()));
        assert (fileSolrModel.getBioformat().equals(file.getBioformat().name()));
        assert (fileSolrModel.getRelease() == file.getRelease());

        Date date = TimeUtils.toDate(file.getCreationDate());
        LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();

        assertEquals(localDate.getYear(), fileSolrModel.getCreationYear());
        assertEquals(localDate.getMonth().toString(), fileSolrModel.getCreationMonth());
        assertEquals(localDate.getDayOfMonth(), fileSolrModel.getCreationDay());
        assertEquals(localDate.getDayOfMonth(), fileSolrModel.getCreationDay());
        assertEquals(localDate.getDayOfWeek().toString(), fileSolrModel.getCreationDayOfWeek());

        assert (fileSolrModel.getStatus().equals(file.getInternal().getStatus().getId()));
        assert (fileSolrModel.isExternal() == file.isExternal());
        assert (fileSolrModel.getSize() == file.getSize());
        assert (fileSolrModel.getSoftwareName().equals(file.getSoftware().getName()));
        assert (fileSolrModel.getNumSamples() == file.getSampleIds().size());

        assertEquals(Arrays.asList(1, 2, 3, 4, 11, 12, 13, 14, 21), fileSolrModel.getAnnotations().get("annotations__im__vsId.a.ab2.ab2c1.ab2c1d1"));
        assertEquals(Arrays.asList(true, false, false), fileSolrModel.getAnnotations().get("annotations__bm__vsId.a.ab1.ab1c1"));
        assertEquals("hello world", fileSolrModel.getAnnotations().get("annotations__s__vsId.a.ab1.ab1c2"));
        assertEquals(Arrays.asList("hello ab2c1d2 1", "hello ab2c1d2 2"), fileSolrModel.getAnnotations().get("annotations__sm__vsId.a.ab2.ab2c1.ab2c1d2"));
        assertEquals(Arrays.asList(Arrays.asList("hello"), Arrays.asList("hello2", "bye2"), Arrays.asList("byeee2", "hellooo2")), fileSolrModel.getAnnotations().get("annotations__sm__vsId.a.ab3.ab3c1.ab3c1d1"));
        assertEquals(Arrays.asList(2.0, 4.0, 24.0), fileSolrModel.getAnnotations().get("annotations__dm__vsId.a.ab3.ab3c1.ab3c1d2"));
        assertNull(fileSolrModel.getAnnotations().get("nothing"));
        assertEquals(fileSolrModel.getAnnotations().keySet().size(), 6);

    }

}

<MSG> Stats: added file annotations for catalog to solr

<DFF> @@ -12,6 +12,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
 
 /**
  * Created by wasim on 13/08/18.
@@ -24,9 +25,9 @@ public class CatalogFileToSolrFileConverterTest {
                 "test/base", "convertorTest", new File.FileStatus("READY"), 1111L, 2);
         file.setUid(111).setSamples(Arrays.asList(new Sample().setId("1"), new Sample().setId("2")))
                 .setExperiment(new Experiment().setName("Experiment")).setSoftware(new Software().setName("Software"));
+        file.setAnnotationSets(AnnotationHelper.createAnnotation());
 
-        CatalogFileToSolrFileConverter converter = new CatalogFileToSolrFileConverter();
-        FileSolrModel fileSolrModel = converter.convertToStorageType(file);
+        FileSolrModel fileSolrModel = new CatalogFileToSolrFileConverter().convertToStorageType(file);
 
         assert (fileSolrModel.getUid() == file.getUid());
         assert (fileSolrModel.getName() == file.getName());
@@ -42,6 +43,15 @@ public class CatalogFileToSolrFileConverterTest {
         assert (fileSolrModel.getExperiment() == file.getExperiment().getName());
         assert (fileSolrModel.getSamples() == file.getSamples().size());
 
+        assertEquals(fileSolrModel.getAnnotations().get("annotations__o__annotName.vsId.a.ab2.ab2c1.ab2c1d1"), Arrays.asList(1, 2, 3, 4, 11, 12, 13, 14, 21));
+        assertEquals(fileSolrModel.getAnnotations().get("annotations__o__annotName.vsId.a.ab1.ab1c1"), Arrays.asList(true, false, false));
+        assertEquals(fileSolrModel.getAnnotations().get("annotations__s__annotName.vsId.a.ab1.ab1c2"), "hello world");
+        assertEquals(fileSolrModel.getAnnotations().get("annotations__o__annotName.vsId.a.ab2.ab2c1.ab2c1d2"), Arrays.asList("hello ab2c1d2 1", "hello ab2c1d2 2"));
+        assertEquals(fileSolrModel.getAnnotations().get("annotations__o__annotName.vsId.a.ab3.ab3c1.ab3c1d1"), Arrays.asList(Arrays.asList("hello"), Arrays.asList("hello2", "bye2"), Arrays.asList("byeee2", "hellooo2")));
+        assertEquals(fileSolrModel.getAnnotations().get("annotations__o__annotName.vsId.a.ab3.ab3c1.ab3c1d2"), Arrays.asList(2.0, 4.0, 24.0));
+        assertNull(fileSolrModel.getAnnotations().get("nothing"));
+        assertEquals(fileSolrModel.getAnnotations().keySet().size(), 6);
+
     }
 
 }

{'addition_count': 12, 'commit_subject': 'Stats: added file annotations for catalog to solr', 'deletion_count': 2, 'file_extension': '.java', 'lang': 'java', 'license': 'apache-2.0', 'repo_name': 'opencb/opencga'}