package uk.ac.ebi.spot.goci.curation.service;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import uk.ac.ebi.spot.goci.builder.AssociationBuilder;
import uk.ac.ebi.spot.goci.curation.validator.SnpFormColumnValidator;
import uk.ac.ebi.spot.goci.curation.validator.SnpFormRowValidator;
import uk.ac.ebi.spot.goci.model.Association;
import uk.ac.ebi.spot.goci.repository.AssociationReportRepository;
import uk.ac.ebi.spot.goci.repository.AssociationRepository;
import uk.ac.ebi.spot.goci.service.MappingService;

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

/**
 * Created by emma on 03/03/2016.
 *
 * @author emma
 *         <p>
 *         Test class for AssociationOperationsService.java
 */
@RunWith(MockitoJUnitRunner.class)
public class AssociationOperationsServiceTest {

    private static final Association ASS_BETA =
            new AssociationBuilder().setId(600L).setBetaNum((float) 0.012).build();

    private static final Association ASS_OR =
            new AssociationBuilder().setId(601L).setOrPerCopyNum((float) 5.97).build();

    private static final Association ASS_NO_EFFECT_SIZE =
            new AssociationBuilder().setId(602L).build();

    private AssociationOperationsService associationOperationsService;

    @Mock
    private SingleSnpMultiSnpAssociationService singleSnpMultiSnpAssociationService;

    @Mock
    private SnpInteractionAssociationService snpInteractionAssociationService;

    @Mock
    private AssociationReportRepository associationReportRepository;

    @Mock
    private AssociationRepository associationRepository;

    @Mock
    private SnpFormRowValidator snpFormRowValidator;

    @Mock
    private SnpFormColumnValidator snpFormColumnValidator;

    @Mock
    private MappingService mappingService;

    @Before
    public void setUpMock() {
        associationOperationsService = new AssociationOperationsService(singleSnpMultiSnpAssociationService,
                                                                        snpInteractionAssociationService,
                                                                        associationReportRepository,
                                                                        snpFormRowValidator,
                                                                        associationRepository,
                                                                        snpFormColumnValidator,
                                                                        mappingService);
    }

    @Test
    public void testMocks() {
        // Test mock creation
        assertNotNull(singleSnpMultiSnpAssociationService);
        assertNotNull(snpInteractionAssociationService);
        assertNotNull(associationReportRepository);
        assertNotNull(snpFormRowValidator);
        assertNotNull(snpFormColumnValidator);
    }

    @Test
    public void testDetermineIfAssociationIsOrType() {
        assertEquals("beta", associationOperationsService.determineIfAssociationIsOrType(ASS_BETA));
        assertEquals("or", associationOperationsService.determineIfAssociationIsOrType(ASS_OR));
        assertEquals("none", associationOperationsService.determineIfAssociationIsOrType(ASS_NO_EFFECT_SIZE));
    }
}

@@ -551,32 +551,87 @@
 tionRepository;%0A
+import uk.ac.ebi.spot.goci.repository.LocusRepository;%0A
 import uk.ac.ebi
@@ -714,54 +714,8 @@
 als;
-%0Aimport static org.junit.Assert.assertNotNull;
 %0A%0A/*
@@ -1907,24 +1907,148 @@
 ngService;%0A%0A
+    @Mock%0A    private LocusRepository locusRepository;%0A%0A    @Mock%0A    private LociAttributesService lociAttributesService;%0A%0A
     @Before%0A
@@ -2397,101 +2397,8 @@
 ry,%0A
-                                                                        snpFormRowValidator,%0A
     
@@ -2480,32 +2480,214 @@
 tionRepository,%0A
+                                                                        locusRepository,%0A                                                                        snpFormRowValidator,%0A
                 
@@ -2856,345 +2856,103 @@
 vice
-);
+,
 %0A    
-%7D%0A%0A
     
-@Test%0A    public void testMocks() %7B%0A        // Test mock creation%0A        assertNotNull(singleSnpMultiSnpAssociationService);%0A        assertNotNull(snpInteractionAssociationService);%0A        assertNotNull(associationReportRepository);%0A        assertNotNull(snpFormRowValidator);%0A        assertNotNull(snpFormColumnValidator
+                                                                lociAttributesService
 );%0A 

Update test to reflect new constructor in test candidate