Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe

Commits:

10 changed files:

Changes:

  • services-client/pom.xml
    ... ... @@ -118,10 +118,6 @@
    118 118
           <groupId>org.nuiton</groupId>
    
    119 119
           <artifactId>nuiton-utils</artifactId>
    
    120 120
         </dependency>
    
    121
    -    <dependency>
    
    122
    -      <groupId>org.nuiton</groupId>
    
    123
    -      <artifactId>nuiton-validator</artifactId>
    
    124
    -    </dependency>
    
    125 121
     
    
    126 122
         <dependency>
    
    127 123
           <groupId>org.nuiton.topia</groupId>
    
    ... ... @@ -195,15 +191,6 @@
    195 191
                   <test>fr.ird.observe.services.client.ServiceClientTestSuite</test>
    
    196 192
                 </configuration>
    
    197 193
               </execution>
    
    198
    -          <execution>
    
    199
    -            <id>default-test</id>
    
    200
    -            <goals>
    
    201
    -              <goal>test</goal>
    
    202
    -            </goals>
    
    203
    -            <configuration>
    
    204
    -              <skip>true</skip>
    
    205
    -            </configuration>
    
    206
    -          </execution>
    
    207 194
             </executions>
    
    208 195
           </plugin>
    
    209 196
     
    

  • services-client/src/test/java/fr/ird/observe/services/client/service/DataSourceServiceClientTest.java
    ... ... @@ -31,6 +31,9 @@ import fr.ird.observe.services.service.BabModelVersionException;
    31 31
     import fr.ird.observe.services.service.DataSourceService;
    
    32 32
     import fr.ird.observe.services.service.DatabaseConnexionNotAuthorizedException;
    
    33 33
     import fr.ird.observe.services.service.DatabaseNotFoundException;
    
    34
    +import fr.ird.observe.services.test.ServiceClientTestClassResource;
    
    35
    +import fr.ird.observe.services.test.ServiceClientTestMethodResource;
    
    36
    +import fr.ird.observe.services.test.ServiceTestSupport;
    
    34 37
     import java.io.IOException;
    
    35 38
     import org.junit.Assert;
    
    36 39
     import org.junit.Ignore;
    
    ... ... @@ -41,7 +44,17 @@ import org.junit.Test;
    41 44
      *
    
    42 45
      * @author Tony Chemit - dev@tchemit.fr
    
    43 46
      */
    
    44
    -public class DataSourceServiceClientTest extends ServiceClientTestSupport {
    
    47
    +public class DataSourceServiceClientTest extends ServiceTestSupport {
    
    48
    +
    
    49
    +    @Override
    
    50
    +    public ServiceClientTestMethodResource getTestMethodResource() {
    
    51
    +        return (ServiceClientTestMethodResource) super.getTestMethodResource();
    
    52
    +    }
    
    53
    +
    
    54
    +    @Override
    
    55
    +    public ServiceClientTestClassResource getTestClassResource() {
    
    56
    +        return (ServiceClientTestClassResource) super.getTestClassResource();
    
    57
    +    }
    
    45 58
     
    
    46 59
         //FIXME
    
    47 60
         @Ignore
    

  • services-client/src/test/java/fr/ird/observe/services/client/service/PingServiceClientTest.java
    ... ... @@ -24,6 +24,8 @@ package fr.ird.observe.services.client.service;
    24 24
     
    
    25 25
     import fr.ird.observe.services.configuration.rest.ObserveDataSourceConfigurationRest;
    
    26 26
     import fr.ird.observe.services.service.PingService;
    
    27
    +import fr.ird.observe.services.test.ServiceClientTestMethodResource;
    
    28
    +import fr.ird.observe.services.test.ServiceTestSupport;
    
    27 29
     import io.ultreia.java4all.http.HResponseNotAvailableException;
    
    28 30
     import java.net.MalformedURLException;
    
    29 31
     import java.net.URL;
    
    ... ... @@ -34,7 +36,12 @@ import org.junit.Test;
    34 36
      *
    
    35 37
      * @author Tony Chemit - dev@tchemit.fr
    
    36 38
      */
    
    37
    -public class PingServiceClientTest extends ServiceClientTestSupport {
    
    39
    +public class PingServiceClientTest extends ServiceTestSupport {
    
    40
    +
    
    41
    +    @Override
    
    42
    +    public ServiceClientTestMethodResource getTestMethodResource() {
    
    43
    +        return (ServiceClientTestMethodResource) super.getTestMethodResource();
    
    44
    +    }
    
    38 45
     
    
    39 46
         @Test(expected = HResponseNotAvailableException.class)
    
    40 47
         public void testPingWithBadServerUrl() throws MalformedURLException, CloneNotSupportedException {
    

  • services-client/src/test/java/fr/ird/observe/services/client/service/ServiceClientTestSupport.java deleted
    1
    -package fr.ird.observe.services.client.service;
    
    2
    -
    
    3
    -/*
    
    4
    - * #%L
    
    5
    - * ObServe :: Services client implementation
    
    6
    - * %%
    
    7
    - * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io
    
    8
    - * %%
    
    9
    - * This program is free software: you can redistribute it and/or modify
    
    10
    - * it under the terms of the GNU General Public License as
    
    11
    - * published by the Free Software Foundation, either version 3 of the
    
    12
    - * License, or (at your option) any later version.
    
    13
    - * 
    
    14
    - * This program is distributed in the hope that it will be useful,
    
    15
    - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    - * GNU General Public License for more details.
    
    18
    - * 
    
    19
    - * You should have received a copy of the GNU General Public
    
    20
    - * License along with this program.  If not, see
    
    21
    - * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    - * #L%
    
    23
    - */
    
    24
    -
    
    25
    -import fr.ird.observe.dto.IdDto;
    
    26
    -import fr.ird.observe.dto.form.Form;
    
    27
    -import fr.ird.observe.services.configuration.ObserveDataSourceConnection;
    
    28
    -import fr.ird.observe.services.configuration.rest.ObserveDataSourceConfigurationRest;
    
    29
    -import fr.ird.observe.services.service.DataSourceService;
    
    30
    -import fr.ird.observe.services.service.ObserveService;
    
    31
    -import fr.ird.observe.services.test.ObserveTestConfiguration;
    
    32
    -import fr.ird.observe.services.test.ServiceClientTestClassResource;
    
    33
    -import fr.ird.observe.services.test.ServiceClientTestMethodResource;
    
    34
    -import fr.ird.observe.services.test.ServiceTestSupport;
    
    35
    -import fr.ird.observe.services.test.spi.DatabaseLoginConfiguration;
    
    36
    -import fr.ird.observe.services.test.spi.DatabasePasswordConfiguration;
    
    37
    -import fr.ird.observe.services.test.spi.DatabaseServerNameConfiguration;
    
    38
    -import fr.ird.observe.services.test.spi.DatabaseUrlConfiguration;
    
    39
    -import org.junit.After;
    
    40
    -import org.junit.Before;
    
    41
    -
    
    42
    -/**
    
    43
    - * @author Tony Chemit - dev@tchemit.fr
    
    44
    - */
    
    45
    -@DatabaseLoginConfiguration(ObserveTestConfiguration.WEB_LOGIN)
    
    46
    -@DatabasePasswordConfiguration(ObserveTestConfiguration.WEB_PASSWORD)
    
    47
    -@DatabaseUrlConfiguration
    
    48
    -@DatabaseServerNameConfiguration
    
    49
    -public abstract class ServiceClientTestSupport extends ServiceTestSupport {
    
    50
    -
    
    51
    -    private ObserveDataSourceConnection dataSourceConnection;
    
    52
    -
    
    53
    -    private DataSourceService dataSourceService;
    
    54
    -
    
    55
    -    @Override
    
    56
    -    public ServiceClientTestClassResource getTestClassResource() {
    
    57
    -        return (ServiceClientTestClassResource) super.getTestClassResource();
    
    58
    -    }
    
    59
    -
    
    60
    -    @Override
    
    61
    -    public ServiceClientTestMethodResource getTestMethodResource() {
    
    62
    -        return (ServiceClientTestMethodResource) super.getTestMethodResource();
    
    63
    -    }
    
    64
    -
    
    65
    -    @Before
    
    66
    -    public void setUp() throws Exception {
    
    67
    -
    
    68
    -        ObserveDataSourceConfigurationRest dataSourceConfiguration = getTestMethodResource().getDataSourceConfiguration();
    
    69
    -
    
    70
    -        dataSourceService = getTestClassResource().newService(dataSourceConfiguration, DataSourceService.class);
    
    71
    -        dataSourceConnection = dataSourceService.open(dataSourceConfiguration);
    
    72
    -    }
    
    73
    -
    
    74
    -    @After
    
    75
    -    public void tearDown() {
    
    76
    -
    
    77
    -        if (dataSourceConnection != null) {
    
    78
    -            dataSourceService.close();
    
    79
    -        }
    
    80
    -
    
    81
    -    }
    
    82
    -
    
    83
    -    public <S extends ObserveService> S newService(Class<S> serviceType) {
    
    84
    -        return getTestClassResource().newService(dataSourceConnection, serviceType);
    
    85
    -    }
    
    86
    -
    
    87
    -    protected <T extends IdDto> void assertEditLabels(Form<T> form, int expectedLabels, Class<?>... expectedTypes) {
    
    88
    -
    
    89
    -        //FIXME Rest test
    
    90
    -//        Assert.assertNotNull(formDto.getLabels());
    
    91
    -//
    
    92
    -//        Set<Class<?>> types = ReferenceSetDtos.getTypes(formDto.getLabels());
    
    93
    -//
    
    94
    -//        Assert.assertEquals(expectedTypes.length, types.size());
    
    95
    -//
    
    96
    -//        for (Class<?> expectedType : expectedTypes) {
    
    97
    -//            Assert.assertTrue(types.contains(expectedType));
    
    98
    -//        }
    
    99
    -//        Assert.assertEquals(expectedLabels, formDto.sizeLabels());
    
    100
    -//
    
    101
    -//        for (ReferenceSetDto referenceSetDto : formDto.getLabels()) {
    
    102
    -//
    
    103
    -//            Assert.assertTrue(referenceSetDto.size() > 0);
    
    104
    -//
    
    105
    -//        }
    
    106
    -    }
    
    107
    -
    
    108
    -    protected <T extends IdDto> void assertReadLabels(Form<T> form, int expectedLabels, Class<?>... expectedTypes) {
    
    109
    -
    
    110
    -        //FIXME Rest test
    
    111
    -//        Assert.assertNotNull(formDto.getLabels());
    
    112
    -//
    
    113
    -//        Set<Class<?>> types = ReferenceSetDtos.getTypes(formDto.getLabels());
    
    114
    -//
    
    115
    -//        Assert.assertEquals(expectedTypes.length, types.size());
    
    116
    -//
    
    117
    -//        for (Class<?> expectedType : expectedTypes) {
    
    118
    -//            Assert.assertTrue(types.contains(expectedType));
    
    119
    -//        }
    
    120
    -//        Assert.assertEquals(expectedLabels, formDto.sizeLabels());
    
    121
    -//
    
    122
    -//        for (ReferenceSetDto referenceSetDto : formDto.getLabels()) {
    
    123
    -//
    
    124
    -//            Assert.assertTrue(referenceSetDto.isReferenceEmpty());
    
    125
    -//
    
    126
    -//        }
    
    127
    -    }
    
    128
    -
    
    129
    -}

  • services-client/src/test/java/fr/ird/observe/services/client/service/actions/consolidate/ConsolidateDataServiceClientTest.java deleted
    1
    -package fr.ird.observe.services.client.service.actions.consolidate;
    
    2
    -
    
    3
    -/*
    
    4
    - * #%L
    
    5
    - * ObServe :: Services client implementation
    
    6
    - * %%
    
    7
    - * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io
    
    8
    - * %%
    
    9
    - * This program is free software: you can redistribute it and/or modify
    
    10
    - * it under the terms of the GNU General Public License as
    
    11
    - * published by the Free Software Foundation, either version 3 of the
    
    12
    - * License, or (at your option) any later version.
    
    13
    - * 
    
    14
    - * This program is distributed in the hope that it will be useful,
    
    15
    - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    - * GNU General Public License for more details.
    
    18
    - * 
    
    19
    - * You should have received a copy of the GNU General Public
    
    20
    - * License along with this program.  If not, see
    
    21
    - * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    - * #L%
    
    23
    - */
    
    24
    -
    
    25
    -import fr.ird.observe.services.service.actions.consolidate.ConsolidateDataServiceTest;
    
    26
    -
    
    27
    -/**
    
    28
    - * Created on 29/08/15.
    
    29
    - *
    
    30
    - * @author Tony Chemit - dev@tchemit.fr
    
    31
    - */
    
    32
    -public class ConsolidateDataServiceClientTest extends ConsolidateDataServiceTest {
    
    33
    -
    
    34
    -}

  • services-client/src/test/java/fr/ird/observe/services/client/service/actions/consolidate/dcp/SimplifiedObjectTypeManagerTest.java deleted
    1
    -package fr.ird.observe.services.client.service.actions.consolidate.dcp;
    
    2
    -
    
    3
    -/*-
    
    4
    - * #%L
    
    5
    - * ObServe :: Services client implementation
    
    6
    - * %%
    
    7
    - * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io
    
    8
    - * %%
    
    9
    - * This program is free software: you can redistribute it and/or modify
    
    10
    - * it under the terms of the GNU General Public License as
    
    11
    - * published by the Free Software Foundation, either version 3 of the
    
    12
    - * License, or (at your option) any later version.
    
    13
    - * 
    
    14
    - * This program is distributed in the hope that it will be useful,
    
    15
    - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    - * GNU General Public License for more details.
    
    18
    - * 
    
    19
    - * You should have received a copy of the GNU General Public
    
    20
    - * License along with this program.  If not, see
    
    21
    - * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    - * #L%
    
    23
    - */
    
    24
    -
    
    25
    -/**
    
    26
    - * Created by tchemit on 02/08/17.
    
    27
    - *
    
    28
    - * @author Tony Chemit - dev@tchemit.fr
    
    29
    - */
    
    30
    -public class SimplifiedObjectTypeManagerTest extends fr.ird.observe.services.service.actions.consolidate.dcp.SimplifiedObjectTypeManagerTest {
    
    31
    -
    
    32
    -}

  • services-client/src/test/java/fr/ird/observe/services/client/service/actions/report/AbstractReportServiceClientTest.java deleted
    1
    -/*
    
    2
    - * #%L
    
    3
    - * ObServe :: Services client implementation
    
    4
    - * %%
    
    5
    - * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io
    
    6
    - * %%
    
    7
    - * This program is free software: you can redistribute it and/or modify
    
    8
    - * it under the terms of the GNU General Public License as
    
    9
    - * published by the Free Software Foundation, either version 3 of the 
    
    10
    - * License, or (at your option) any later version.
    
    11
    - * 
    
    12
    - * This program is distributed in the hope that it will be useful,
    
    13
    - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    14
    - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    15
    - * GNU General Public License for more details.
    
    16
    - * 
    
    17
    - * You should have received a copy of the GNU General Public 
    
    18
    - * License along with this program.  If not, see
    
    19
    - * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    20
    - * #L%
    
    21
    - */
    
    22
    -package fr.ird.observe.services.client.service.actions.report;
    
    23
    -
    
    24
    -
    
    25
    -import fr.ird.observe.dto.reference.DtoReference;
    
    26
    -import fr.ird.observe.services.client.service.ServiceClientTestSupport;
    
    27
    -import fr.ird.observe.services.service.actions.report.DataMatrix;
    
    28
    -import fr.ird.observe.services.service.actions.report.Report;
    
    29
    -import fr.ird.observe.services.service.actions.report.ReportBuilder;
    
    30
    -import fr.ird.observe.services.service.actions.report.ReportRequest;
    
    31
    -import fr.ird.observe.services.service.actions.report.ReportService;
    
    32
    -import fr.ird.observe.services.service.actions.report.ReportVariable;
    
    33
    -import fr.ird.observe.test.ObserveFixtures;
    
    34
    -import java.io.IOException;
    
    35
    -import java.net.URL;
    
    36
    -import java.util.List;
    
    37
    -import org.apache.commons.logging.Log;
    
    38
    -import org.apache.commons.logging.LogFactory;
    
    39
    -import org.junit.Assert;
    
    40
    -import org.junit.Before;
    
    41
    -import org.junit.Test;
    
    42
    -
    
    43
    -/**
    
    44
    - * Classe abstraite de test d'un report.
    
    45
    - * <p>
    
    46
    - * On définit ici le mécanisme pour tester unitairement un report et son
    
    47
    - * résultat.
    
    48
    - *
    
    49
    - * @author Tony Chemit - dev@tchemit.fr
    
    50
    - * @since 1.9
    
    51
    - */
    
    52
    -public abstract class AbstractReportServiceClientTest extends ServiceClientTestSupport {
    
    53
    -
    
    54
    -    /** Logger */
    
    55
    -    private static final Log log = LogFactory.getLog(AbstractReportServiceClientTest.class);
    
    56
    -
    
    57
    -    protected ReportService service;
    
    58
    -
    
    59
    -    /** La liste de tous les reports connus. */
    
    60
    -    protected static List<Report> reports;
    
    61
    -
    
    62
    -    /** Le report à tester. */
    
    63
    -    private Report report;
    
    64
    -
    
    65
    -    protected abstract String getReportId();
    
    66
    -
    
    67
    -    @Before
    
    68
    -    public final void setUp() throws Exception {
    
    69
    -
    
    70
    -        super.setUp();
    
    71
    -
    
    72
    -        service = newService(ReportService.class);
    
    73
    -
    
    74
    -        // recuperation du report à tester
    
    75
    -        report = getReport(log, getReportId());
    
    76
    -
    
    77
    -        if (log.isInfoEnabled()) {
    
    78
    -            log.info("Will use report '" + report + "'");
    
    79
    -        }
    
    80
    -
    
    81
    -    }
    
    82
    -
    
    83
    -
    
    84
    -    /**
    
    85
    -     * L'unique test à lancer.
    
    86
    -     * <p>
    
    87
    -     * On vérifie :
    
    88
    -     * <ul>
    
    89
    -     * <li>la syntaxe du report via {@link #testReportSyntax(Report)}</li>
    
    90
    -     * <li>le résultat du report via {@link #testReportResult(DataMatrix)}</li>
    
    91
    -     * </ul>
    
    92
    -     *
    
    93
    -     * @throws Exception pour toute erreur lors de l'execution du report
    
    94
    -     */
    
    95
    -    @Test
    
    96
    -    public final void testReport() throws Exception {
    
    97
    -
    
    98
    -        // test de la syntaxe du report
    
    99
    -        testReportSyntax(report);
    
    100
    -
    
    101
    -        // creation de l'executeur de report
    
    102
    -        report = service.populateVariables(report, ObserveFixtures.TRIP_SEINE_ID_1);
    
    103
    -
    
    104
    -        // preparation des variables
    
    105
    -        prepareVariables();
    
    106
    -
    
    107
    -
    
    108
    -        // on execute le report
    
    109
    -        DataMatrix result = service.executeReport(report, ObserveFixtures.TRIP_SEINE_ID_1);
    
    110
    -
    
    111
    -        if (log.isInfoEnabled()) {
    
    112
    -            log.info("Result :\n" + result.getClipboardContent(true, true, false, '\t'));
    
    113
    -        }
    
    114
    -
    
    115
    -        // on verifie le resultat
    
    116
    -        testReportResult(result);
    
    117
    -    }
    
    118
    -
    
    119
    -    protected void prepareVariables() {
    
    120
    -
    
    121
    -    }
    
    122
    -
    
    123
    -    protected void setVariableValue(String variableName, String id) {
    
    124
    -
    
    125
    -        for (ReportVariable variable : report.getVariables()) {
    
    126
    -
    
    127
    -            if (variableName.equals(variable.getName())) {
    
    128
    -
    
    129
    -                Object value = variable.getValues().stream()
    
    130
    -                        .filter(DtoReference.newIdPredicate(id))
    
    131
    -                        .findFirst()
    
    132
    -                        .orElse(null);
    
    133
    -
    
    134
    -                variable.setSelectedValue(value);
    
    135
    -
    
    136
    -            }
    
    137
    -
    
    138
    -        }
    
    139
    -
    
    140
    -    }
    
    141
    -
    
    142
    -    protected abstract void testReportSyntax(Report report);
    
    143
    -
    
    144
    -    protected abstract void testReportResult(DataMatrix result);
    
    145
    -
    
    146
    -    protected static Report getReport(Log log, String reportId) throws IOException {
    
    147
    -        if (reports == null) {
    
    148
    -
    
    149
    -            URL reportLocation =
    
    150
    -                    AbstractReportServiceClientTest.class.getResource("/observe-reports.properties");
    
    151
    -
    
    152
    -            if (log.isInfoEnabled()) {
    
    153
    -                log.info("Loading reports from " + reportLocation);
    
    154
    -            }
    
    155
    -
    
    156
    -            ReportBuilder builder = new ReportBuilder();
    
    157
    -
    
    158
    -            reports = builder.load(reportLocation);
    
    159
    -
    
    160
    -            builder.clear();
    
    161
    -
    
    162
    -            Assert.assertNotNull(reports);
    
    163
    -            Assert.assertFalse(reports.isEmpty());
    
    164
    -        }
    
    165
    -
    
    166
    -        Report result = null;
    
    167
    -        // recuperation du report à tester
    
    168
    -        for (Report report : reports) {
    
    169
    -            if (reportId.equals(report.getId())) {
    
    170
    -                result = report;
    
    171
    -                break;
    
    172
    -            }
    
    173
    -        }
    
    174
    -
    
    175
    -        Assert.assertNotNull("Could not find report with id " + reportId, reports);
    
    176
    -        return result;
    
    177
    -    }
    
    178
    -
    
    179
    -    protected void assertReportName(Report report,
    
    180
    -                                    String name,
    
    181
    -                                    String description) {
    
    182
    -        Assert.assertEquals(getReportId(), report.getId());
    
    183
    -        Assert.assertEquals(name, report.getName());
    
    184
    -        Assert.assertEquals(description, report.getDescription());
    
    185
    -    }
    
    186
    -
    
    187
    -    protected void assertReportDimension(Report report,
    
    188
    -                                         int rows,
    
    189
    -                                         int columns,
    
    190
    -                                         String[] columnsHeader,
    
    191
    -                                         String[] rowsHeader) {
    
    192
    -        Assert.assertEquals(rows, report.getRows());
    
    193
    -        Assert.assertEquals(columns, report.getColumns());
    
    194
    -        Assert.assertArrayEquals(columnsHeader, report.getColumnHeaders());
    
    195
    -        Assert.assertArrayEquals(rowsHeader, report.getRowHeaders());
    
    196
    -    }
    
    197
    -
    
    198
    -    protected void assertReportNbRequests(Report report, int nbRequests) {
    
    199
    -        ReportRequest[] requests = report.getRequests();
    
    200
    -        Assert.assertNotNull(requests);
    
    201
    -        Assert.assertEquals(nbRequests, requests.length);
    
    202
    -    }
    
    203
    -
    
    204
    -    protected void assertReportRequestDimension(ReportRequest request,
    
    205
    -                                                ReportRequest.RequestLayout layout,
    
    206
    -                                                int x,
    
    207
    -                                                int y) {
    
    208
    -        Assert.assertEquals(layout, request.getLayout());
    
    209
    -//        Assert.assertEquals(new Point(width, height), request.getLocation());
    
    210
    -        Assert.assertEquals(x, request.getX());
    
    211
    -        Assert.assertEquals(y, request.getY());
    
    212
    -    }
    
    213
    -
    
    214
    -    protected void assertResultDimension(DataMatrix result,
    
    215
    -                                         int width,
    
    216
    -                                         int height,
    
    217
    -                                         int x,
    
    218
    -                                         int y) {
    
    219
    -        Assert.assertEquals(width, result.getWidth());
    
    220
    -        Assert.assertEquals(height, result.getHeight());
    
    221
    -        Assert.assertEquals(x, result.getX());
    
    222
    -        Assert.assertEquals(y, result.getY());
    
    223
    -    }
    
    224
    -
    
    225
    -    protected void assertResultRow(DataMatrix result, int rowId, Object... row) {
    
    226
    -        Object[] actualRow = result.getData()[rowId];
    
    227
    -        Assert.assertArrayEquals(row, actualRow);
    
    228
    -    }
    
    229
    -}

  • services-client/src/test/java/fr/ird/observe/services/client/service/actions/report/ReportAccessoryCatchClientTest.java deleted
    1
    -/*
    
    2
    - * #%L
    
    3
    - * ObServe :: Services client implementation
    
    4
    - * %%
    
    5
    - * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io
    
    6
    - * %%
    
    7
    - * This program is free software: you can redistribute it and/or modify
    
    8
    - * it under the terms of the GNU General Public License as
    
    9
    - * published by the Free Software Foundation, either version 3 of the 
    
    10
    - * License, or (at your option) any later version.
    
    11
    - * 
    
    12
    - * This program is distributed in the hope that it will be useful,
    
    13
    - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    14
    - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    15
    - * GNU General Public License for more details.
    
    16
    - * 
    
    17
    - * You should have received a copy of the GNU General Public 
    
    18
    - * License along with this program.  If not, see
    
    19
    - * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    20
    - * #L%
    
    21
    - */
    
    22
    -package fr.ird.observe.services.client.service.actions.report;
    
    23
    -
    
    24
    -
    
    25
    -import fr.ird.observe.services.service.actions.report.DataMatrix;
    
    26
    -import fr.ird.observe.services.service.actions.report.Report;
    
    27
    -import fr.ird.observe.services.service.actions.report.ReportRequest;
    
    28
    -import fr.ird.observe.test.ObserveFixtures;
    
    29
    -import org.junit.Assert;
    
    30
    -
    
    31
    -/**
    
    32
    - * Test du report {@code accessoryCatch}.
    
    33
    - *
    
    34
    - * @author Tony Chemit - dev@tchemit.fr
    
    35
    - * @since 1.9
    
    36
    - */
    
    37
    -public class ReportAccessoryCatchClientTest extends AbstractReportServiceClientTest {
    
    38
    -
    
    39
    -    @Override
    
    40
    -    protected void testReportSyntax(Report report) {
    
    41
    -        Assert.assertNotNull(report);
    
    42
    -        assertReportName(
    
    43
    -                report,
    
    44
    -                "Liste des captures accessoires selon le type de banc, filtrées par groupe",
    
    45
    -                "Afficher les captures accessoires par groupe d'espèce\n" +
    
    46
    -                        "Les poids sont exprimés en tonnes."
    
    47
    -        );
    
    48
    -
    
    49
    -        assertReportDimension(
    
    50
    -                report,
    
    51
    -                -1,
    
    52
    -                3,
    
    53
    -                new String[]{"Espèce",
    
    54
    -                        "Banc libre",
    
    55
    -                        "Banc objet",
    
    56
    -                },
    
    57
    -                null
    
    58
    -        );
    
    59
    -
    
    60
    -        assertReportNbRequests(report, 3);
    
    61
    -
    
    62
    -        ReportRequest[] requests = report.getRequests();
    
    63
    -
    
    64
    -        assertReportRequestDimension(
    
    65
    -                requests[0],
    
    66
    -                ReportRequest.RequestLayout.row,
    
    67
    -                0,
    
    68
    -                0
    
    69
    -        );
    
    70
    -        assertReportRequestDimension(
    
    71
    -                requests[1],
    
    72
    -                ReportRequest.RequestLayout.row,
    
    73
    -                1,
    
    74
    -                0
    
    75
    -        );
    
    76
    -        assertReportRequestDimension(
    
    77
    -                requests[2],
    
    78
    -                ReportRequest.RequestLayout.row,
    
    79
    -                2,
    
    80
    -                0
    
    81
    -        );
    
    82
    -    }
    
    83
    -
    
    84
    -    @Override
    
    85
    -    protected String getReportId() {
    
    86
    -        return "accessoryCatch";
    
    87
    -    }
    
    88
    -
    
    89
    -    @Override
    
    90
    -    protected void prepareVariables() {
    
    91
    -        setVariableValue("speciesGroup", ObserveFixtures.SPECIES_GROUP_ID);
    
    92
    -    }
    
    93
    -
    
    94
    -    @Override
    
    95
    -    protected void testReportResult(DataMatrix result) {
    
    96
    -        assertResultDimension(result, 3, 54, 0, 0);
    
    97
    -
    
    98
    -        int row = 0;
    
    99
    -        assertResultRow(result, row++, "[FAO]MAE [sc]Aetobatus narinari [fr]Aigle de mer léopard", "-", "-");
    
    100
    -        assertResultRow(result, row++, "[FAO]PTH [sc]Alopias pelagicus [fr]Renard pélagique", "-", "-");
    
    101
    -        assertResultRow(result, row++, "[FAO]BTH [sc]Alopias superciliosus [fr]Renard à gros yeux", "-", "-");
    
    102
    -        assertResultRow(result, row++, "[FAO]ALV [sc]Alopias vulpinus [fr]Renard", "-", "-");
    
    103
    -        assertResultRow(result, row++, "[FAO]WSH [sc]Carcharodon carcharias [fr]Grand requin blanc", "-", "-");
    
    104
    -        assertResultRow(result, row++, "[FAO]CCE [sc]Carcharhinus leucas [fr]Requin-bouledogue", "-", "-");
    
    105
    -        assertResultRow(result, row++, "[FAO]FAL [sc]Carcharhinus falciformis [fr]Requin soyeux", "-", "+ Effectif : 17 Poids total (t) : 0.1753");
    
    106
    -        assertResultRow(result, row++, "[FAO]OCS [sc]Carcharhinus longimanus [fr]Requin océanique", "+ Effectif : 1 Poids total (t) : 0.0447", "-");
    
    107
    -        assertResultRow(result, row++, "[FAO]DUS [sc]Carcharhinus obscurus [fr]Requin sombre", "-", "-");
    
    108
    -        assertResultRow(result, row++, "[FAO]PLS [sc]Dasyatys (Pteroplatytrygon) violacea [fr]Pastenague violette", "-", "-");
    
    109
    -        assertResultRow(result, row++, "[FAO]SHL [sc]Etmopterus spp [fr]Genre Etmopterus", "-", "-");
    
    110
    -        assertResultRow(result, row++, "[FAO]THR [sc]Alopias spp [fr]Renards de mer nca ", "-", "-");
    
    111
    -        assertResultRow(result, row++, "[FAO]RSK [sc]Carcharhinidae spp [fr]Famille Carcharhinidae", "-", "+ Effectif : 11 Poids total (t) : 0.55");
    
    112
    -        assertResultRow(result, row++, "[FAO]STT [sc]Dasyatidae [fr]Famille Dasyatidae", "+ Effectif : 7 Poids total (t) : 0.015", "-");
    
    113
    -        assertResultRow(result, row++, "[FAO]MSK [sc]Lamnidae [fr]Famille Lamnidae", "-", "-");
    
    114
    -        assertResultRow(result, row++, "[FAO]2FOD [sc]Odontaspididae [fr]Odontaspididae", "-", "-");
    
    115
    -        assertResultRow(result, row++, "[FAO]- [sc]Rhincodontidae [fr]Famille Rhincodontidae", "-", "-");
    
    116
    -        assertResultRow(result, row++, "[FAO]SPY [sc]Sphyrnidae [fr]Famille Sphyrnidae", "-", "+ Effectif : 1");
    
    117
    -        assertResultRow(result, row++, "[FAO]TIG [sc]Galeocerdo cuvier [fr]Requin tigre commun", "-", "-");
    
    118
    -        assertResultRow(result, row++, "[FAO]ISB [sc]Isistius brasiliensis [fr]Squalelet féroce", "-", "-");
    
    119
    -        assertResultRow(result, row++, "[FAO]SMA [sc]Isurus oxyrinchus [fr]Taupe bleu", "-", "-");
    
    120
    -        assertResultRow(result, row++, "[FAO]MAK [sc]Isurus spp [fr]Taupes", "-", "-");
    
    121
    -        assertResultRow(result, row++, "[FAO]MAN [sc]Mobulidae  [fr]Mantes, diables de mer nca ", "-", "-");
    
    122
    -        assertResultRow(result, row++, "[FAO]MYL [sc]Myliobatis aquila [fr]Aigle commun", "-", "-");
    
    123
    -        assertResultRow(result, row++, "[FAO]RMB [sc]Manta birostris [fr]Mante atlantique", "+ Effectif : 9 Poids total (t) : 1.1824", "-");
    
    124
    -        assertResultRow(result, row++, "[FAO]RMT [sc]Mobula tarapacana [fr]Diable géant de Guinée", "-", "-");
    
    125
    -        assertResultRow(result, row++, "[FAO]MNT [sc]Manta spp [fr]Raies manta", "-", "-");
    
    126
    -        assertResultRow(result, row++, "[FAO]RMM [sc]Mobula mobular [fr]Mante mobula", "-", "-");
    
    127
    -        assertResultRow(result, row++, "[FAO]LMP [sc]Megachasma pelagios [fr]Requin grande gueule", "-", "-");
    
    128
    -        assertResultRow(result, row++, "[FAO]RMJ [sc]Mobula japanica [fr]Mante aiguillat", "-", "-");
    
    129
    -        assertResultRow(result, row++, "[FAO]CVX [sc]Carcharhiniformes [fr]Ordre Carcharhiniformes", "-", "-");
    
    130
    -        assertResultRow(result, row++, "[FAO]HDQ [sc]Heterodontiformes [fr]Ordre Heterodontiformes", "-", "-");
    
    131
    -        assertResultRow(result, row++, "[FAO]HXW [sc]Hexanchiformes [fr]Ordre Hexanchiformes", "-", "-");
    
    132
    -        assertResultRow(result, row++, "[FAO]LMZ [sc]Lamniformes [fr]Ordre Lamniformes", "-", "-");
    
    133
    -        assertResultRow(result, row++, "[FAO]OCX [sc]Orectolobiformes [fr]Ordre Orectolobiformes", "-", "-");
    
    134
    -        assertResultRow(result, row++, "[FAO]PWS [sc]Pristiophorus spp [fr]Requins-scies nca ", "-", "-");
    
    135
    -        assertResultRow(result, row++, "[FAO]SHX [sc]Squaliformes [fr]Ordre Squaliformes", "-", "-");
    
    136
    -        assertResultRow(result, row++, "[FAO]ASK [sc]Squatinidae [fr]Anges de mer nca ", "-", "-");
    
    137
    -        assertResultRow(result, row++, "[FAO]BSH [sc]Prionace glauca [fr]Peau bleue", "-", "-");
    
    138
    -        assertResultRow(result, row++, "[FAO]POR [sc]Lamna nasus [fr]Requin taupe commun", "-", "-");
    
    139
    -        assertResultRow(result, row++, "[FAO]SRX [sc]Raie non identifiée [fr]Raie non identifiée", "-", "-");
    
    140
    -        assertResultRow(result, row++, "[FAO]2REX [sc]Requin non identifié [fr]Requin non identifié", "-", "-");
    
    141
    -        assertResultRow(result, row++, "[FAO]- [sc]Rhinopteridae [fr]Famille Rhinopteridae", "-", "-");
    
    142
    -        assertResultRow(result, row++, "[FAO]NZX [sc]Rhinoptera spp [fr]Mourines", "-", "-");
    
    143
    -        assertResultRow(result, row++, "[FAO]RMA [sc]Manta alfredi [fr]Manta Alfredi", "-", "-");
    
    144
    -        assertResultRow(result, row++, "[FAO]RMC [sc]Mobula coilloti  [fr]Mobula coilloti ", "-", "-");
    
    145
    -        assertResultRow(result, row++, "[FAO]RMO [sc]Mobula thurstoni [fr]Mobula", "-", "-");
    
    146
    -        assertResultRow(result, row++, "[FAO]RMV [sc]Mobula spp [fr]Mobula nca", "-", "-");
    
    147
    -        assertResultRow(result, row++, "[FAO]BSK [sc]Cetorhinus maximus [fr]Requin pèlerin", "-", "-");
    
    148
    -        assertResultRow(result, row++, "[FAO]RHN [sc]Rhincodon typus [fr]Requin baleine", "-", "-");
    
    149
    -        assertResultRow(result, row++, "[FAO]SPL [sc]Sphyrna lewini [fr]Requin marteau halicorne", "-", "-");
    
    150
    -        assertResultRow(result, row++, "[FAO]SPK [sc]Sphyrna mokarran [fr]Grand requin marteau", "-", "-");
    
    151
    -        assertResultRow(result, row++, "[FAO]SPZ [sc]Sphyrna zygaena [fr]Requin marteau commun", "-", "-");
    
    152
    -        assertResultRow(result, row, "[FAO]TOD [sc]Torpedinidae [fr]Torpilles, raies électriq. nca ", "-", "-");
    
    153
    -
    
    154
    -
    
    155
    -    }
    
    156
    -}

  • services-client/src/test/java/fr/ird/observe/services/client/service/actions/validate/ValidateServiceClientTest.java deleted
    1
    -package fr.ird.observe.services.client.service.actions.validate;
    
    2
    -
    
    3
    -/*
    
    4
    - * #%L
    
    5
    - * ObServe :: Services client implementation
    
    6
    - * %%
    
    7
    - * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io
    
    8
    - * %%
    
    9
    - * This program is free software: you can redistribute it and/or modify
    
    10
    - * it under the terms of the GNU General Public License as
    
    11
    - * published by the Free Software Foundation, either version 3 of the
    
    12
    - * License, or (at your option) any later version.
    
    13
    - * 
    
    14
    - * This program is distributed in the hope that it will be useful,
    
    15
    - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    - * GNU General Public License for more details.
    
    18
    - * 
    
    19
    - * You should have received a copy of the GNU General Public
    
    20
    - * License along with this program.  If not, see
    
    21
    - * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    - * #L%
    
    23
    - */
    
    24
    -
    
    25
    -import com.google.common.collect.ImmutableSet;
    
    26
    -import fr.ird.observe.dto.referential.CountryDto;
    
    27
    -import fr.ird.observe.dto.referential.FpaZoneDto;
    
    28
    -import fr.ird.observe.dto.referential.GearCaracteristicDto;
    
    29
    -import fr.ird.observe.dto.referential.GearCaracteristicTypeDto;
    
    30
    -import fr.ird.observe.dto.referential.GearDto;
    
    31
    -import fr.ird.observe.dto.referential.HarbourDto;
    
    32
    -import fr.ird.observe.dto.referential.LengthWeightParameterDto;
    
    33
    -import fr.ird.observe.dto.referential.OceanDto;
    
    34
    -import fr.ird.observe.dto.referential.OrganismDto;
    
    35
    -import fr.ird.observe.dto.referential.PersonDto;
    
    36
    -import fr.ird.observe.dto.referential.ProgramDto;
    
    37
    -import fr.ird.observe.dto.referential.ReferentialDto;
    
    38
    -import fr.ird.observe.dto.referential.SexDto;
    
    39
    -import fr.ird.observe.dto.referential.SpeciesDto;
    
    40
    -import fr.ird.observe.dto.referential.SpeciesGroupDto;
    
    41
    -import fr.ird.observe.dto.referential.SpeciesListDto;
    
    42
    -import fr.ird.observe.dto.referential.VesselDto;
    
    43
    -import fr.ird.observe.dto.referential.VesselSizeCategoryDto;
    
    44
    -import fr.ird.observe.dto.referential.VesselTypeDto;
    
    45
    -import fr.ird.observe.services.client.service.ServiceClientTestSupport;
    
    46
    -import fr.ird.observe.services.service.actions.validate.DataValidationRequest;
    
    47
    -import fr.ird.observe.services.service.actions.validate.ReferentialValidationRequest;
    
    48
    -import fr.ird.observe.services.service.actions.validate.ValidateService;
    
    49
    -import fr.ird.observe.services.service.actions.validate.ValidationResult;
    
    50
    -import fr.ird.observe.test.ObserveFixtures;
    
    51
    -import org.junit.Assert;
    
    52
    -import org.junit.Test;
    
    53
    -import org.nuiton.validator.NuitonValidatorScope;
    
    54
    -
    
    55
    -/**
    
    56
    - * @author Tony Chemit - dev@tchemit.fr
    
    57
    - */
    
    58
    -public class ValidateServiceClientTest extends ServiceClientTestSupport {
    
    59
    -
    
    60
    -    protected static final ImmutableSet<Class<? extends ReferentialDto>> REFERENTIAL_DTO_TYPES = ImmutableSet.of(
    
    61
    -            CountryDto.class,
    
    62
    -            FpaZoneDto.class,
    
    63
    -            GearCaracteristicDto.class,
    
    64
    -            GearCaracteristicTypeDto.class,
    
    65
    -            GearDto.class,
    
    66
    -            HarbourDto.class,
    
    67
    -            LengthWeightParameterDto.class,
    
    68
    -            OceanDto.class,
    
    69
    -            OrganismDto.class,
    
    70
    -            PersonDto.class,
    
    71
    -            ProgramDto.class,
    
    72
    -            SexDto.class,
    
    73
    -            SpeciesDto.class,
    
    74
    -            SpeciesGroupDto.class,
    
    75
    -            SpeciesListDto.class,
    
    76
    -            VesselDto.class,
    
    77
    -            VesselSizeCategoryDto.class,
    
    78
    -            VesselTypeDto.class
    
    79
    -    );
    
    80
    -
    
    81
    -    protected ValidateService service;
    
    82
    -
    
    83
    -    @Override
    
    84
    -    public void setUp() throws Exception {
    
    85
    -        super.setUp();
    
    86
    -        service = newService(ValidateService.class);
    
    87
    -
    
    88
    -    }
    
    89
    -
    
    90
    -    @Test
    
    91
    -    public void testValidateReferantials() throws Exception {
    
    92
    -
    
    93
    -        ReferentialValidationRequest request = new ReferentialValidationRequest();
    
    94
    -
    
    95
    -        request.setValidationContext(ValidateService.UPDATE_VALIDATION_CONTEXT);
    
    96
    -        request.setScopes(ImmutableSet.copyOf(NuitonValidatorScope.values()));
    
    97
    -
    
    98
    -        request.setReferentialTypes(REFERENTIAL_DTO_TYPES);
    
    99
    -
    
    100
    -        ValidationResult<ReferentialValidationRequest> result = service.validateReferential(request);
    
    101
    -        Assert.assertNotNull(result);
    
    102
    -        //FIXME
    
    103
    -
    
    104
    -//        ImmutableMap<Class<? extends ReferentialDto>, ValidateResultForDtoType<? extends IdDto>> resultByType = result.getResultByType();
    
    105
    -//        Assert.assertNotNull(resultByType);
    
    106
    -//        Assert.assertEquals(59, resultByType.size());
    
    107
    -//
    
    108
    -//        assertValidateResultForReferentialDtoType(resultByType, CountryDto.class, 53);
    
    109
    -//        assertValidateResultForReferentialDtoType(resultByType, FpaZoneDto.class, 41);
    
    110
    -//        assertValidateResultForReferentialDtoType(resultByType, GearCaracteristicDto.class, 22);
    
    111
    -//        assertValidateResultForReferentialDtoType(resultByType, GearCaracteristicTypeDto.class, 6);
    
    112
    -//        assertValidateResultForReferentialDtoType(resultByType, GearDto.class, 26);
    
    113
    -//        assertValidateResultForReferentialDtoType(resultByType, HarbourDto.class, 74);
    
    114
    -//        assertValidateResultForReferentialDtoType(resultByType, LengthWeightParameterDto.class, 352);
    
    115
    -//        assertValidateResultForReferentialDtoType(resultByType, OceanDto.class, 3);
    
    116
    -//        assertValidateResultForReferentialDtoType(resultByType, OrganismDto.class, 8);
    
    117
    -//        assertValidateResultForReferentialDtoType(resultByType, PersonDto.class, 390);
    
    118
    -//        assertValidateResultForReferentialDtoType(resultByType, ProgramDto.class, 27);
    
    119
    -//        assertValidateResultForReferentialDtoType(resultByType, SexDto.class, 5);
    
    120
    -//        assertValidateResultForReferentialDtoType(resultByType, SpeciesDto.class, 275);
    
    121
    -//        assertValidateResultForReferentialDtoType(resultByType, SpeciesGroupDto.class, 8);
    
    122
    -//        assertValidateResultForReferentialDtoType(resultByType, SpeciesListDto.class, 5);
    
    123
    -//        assertValidateResultForReferentialDtoType(resultByType, VesselDto.class, 977);
    
    124
    -//        assertValidateResultForReferentialDtoType(resultByType, VesselSizeCategoryDto.class, 13);
    
    125
    -//        assertValidateResultForReferentialDtoType(resultByType, VesselTypeDto.class, 14);
    
    126
    -//
    
    127
    -//        assertValidateResultForReferentialDtoType(resultByType, BaitHaulingStatusDto.class, 5);
    
    128
    -//        assertValidateResultForReferentialDtoType(resultByType, BaitSettingStatusDto.class, 5);
    
    129
    -//        assertValidateResultForReferentialDtoType(resultByType, BaitTypeDto.class, 16);
    
    130
    -//        assertValidateResultForReferentialDtoType(resultByType, CatchFateLonglineDto.class, 5);
    
    131
    -//        assertValidateResultForReferentialDtoType(resultByType, EncounterTypeDto.class, 12);
    
    132
    -//        assertValidateResultForReferentialDtoType(resultByType, HealthnessDto.class, 6);
    
    133
    -//        assertValidateResultForReferentialDtoType(resultByType, HookPositionDto.class, 13);
    
    134
    -//        assertValidateResultForReferentialDtoType(resultByType, HookSizeDto.class, 22);
    
    135
    -//        assertValidateResultForReferentialDtoType(resultByType, HookTypeDto.class, 13);
    
    136
    -//        assertValidateResultForReferentialDtoType(resultByType, ItemHorizontalPositionDto.class, 3);
    
    137
    -//        assertValidateResultForReferentialDtoType(resultByType, ItemVerticalPositionDto.class, 3);
    
    138
    -//        assertValidateResultForReferentialDtoType(resultByType, LightsticksColorDto.class, 7);
    
    139
    -//        assertValidateResultForReferentialDtoType(resultByType, LightsticksTypeDto.class, 2);
    
    140
    -//        assertValidateResultForReferentialDtoType(resultByType, LineTypeDto.class, 8);
    
    141
    -//        assertValidateResultForReferentialDtoType(resultByType, MaturityStatusDto.class, 12);
    
    142
    -//        assertValidateResultForReferentialDtoType(resultByType, MitigationTypeDto.class, 15);
    
    143
    -//        assertValidateResultForReferentialDtoType(resultByType, SensorBrandDto.class, 4);
    
    144
    -//        assertValidateResultForReferentialDtoType(resultByType, SensorDataFormatDto.class, 2);
    
    145
    -//        assertValidateResultForReferentialDtoType(resultByType, SensorTypeDto.class, 4);
    
    146
    -//        assertValidateResultForReferentialDtoType(resultByType, SettingShapeDto.class, 6);
    
    147
    -//        assertValidateResultForReferentialDtoType(resultByType, SizeMeasureTypeDto.class, 17);
    
    148
    -//        assertValidateResultForReferentialDtoType(resultByType, StomacFullnessDto.class, 7);
    
    149
    -//        assertValidateResultForReferentialDtoType(resultByType, TripTypeDto.class, 3);
    
    150
    -//        assertValidateResultForReferentialDtoType(resultByType, VesselActivityLonglineDto.class, 5);
    
    151
    -//        assertValidateResultForReferentialDtoType(resultByType, WeightMeasureTypeDto.class, 3);
    
    152
    -//
    
    153
    -//        assertValidateResultForReferentialDtoType(resultByType, DetectionModeDto.class, 10);
    
    154
    -//        assertValidateResultForReferentialDtoType(resultByType, ObjectOperationDto.class, 4);
    
    155
    -//        assertValidateResultForReferentialDtoType(resultByType, ObservedSystemDto.class, 21);
    
    156
    -//        assertValidateResultForReferentialDtoType(resultByType, ReasonForDiscardDto.class, 5);
    
    157
    -//        assertValidateResultForReferentialDtoType(resultByType, ReasonForNoFishingDto.class, 13);
    
    158
    -//        assertValidateResultForReferentialDtoType(resultByType, ReasonForNullSetDto.class, 10);
    
    159
    -//        assertValidateResultForReferentialDtoType(resultByType, SpeciesFateDto.class, 9);
    
    160
    -//        assertValidateResultForReferentialDtoType(resultByType, SpeciesStatusDto.class, 3);
    
    161
    -//        assertValidateResultForReferentialDtoType(resultByType, SurroundingActivityDto.class, 8);
    
    162
    -//        assertValidateResultForReferentialDtoType(resultByType, TransmittingBuoyOperationDto.class, 3);
    
    163
    -//        assertValidateResultForReferentialDtoType(resultByType, TransmittingBuoyTypeDto.class, 12);
    
    164
    -//        assertValidateResultForReferentialDtoType(resultByType, VesselActivitySeineDto.class, 23);
    
    165
    -//        assertValidateResultForReferentialDtoType(resultByType, WeightCategoryDto.class, 101);
    
    166
    -//        assertValidateResultForReferentialDtoType(resultByType, WindDto.class, 13);
    
    167
    -
    
    168
    -    }
    
    169
    -
    
    170
    -    @Test
    
    171
    -    public void testValidateTripSeinesCreate() throws Exception {
    
    172
    -
    
    173
    -        DataValidationRequest request = new DataValidationRequest();
    
    174
    -
    
    175
    -        request.setValidationContext(ValidateService.UPDATE_VALIDATION_CONTEXT);
    
    176
    -        request.setScopes(ImmutableSet.copyOf(NuitonValidatorScope.values()));
    
    177
    -        request.setDataIds(ImmutableSet.of(ObserveFixtures.TRIP_SEINE_ID_1, ObserveFixtures.TRIP_SEINE_ID_2));
    
    178
    -
    
    179
    -        ValidationResult<DataValidationRequest> result = service.validateData(request);
    
    180
    -        Assert.assertNotNull(result);
    
    181
    -        //FIXME
    
    182
    -//        ImmutableMap<Class<? extends IdDto>, ValidateResultForDtoType<? extends IdDto>> resultByType = result.getResultByType();
    
    183
    -//        Assert.assertNotNull(resultByType);
    
    184
    -//        Assert.assertEquals(5, resultByType.size());
    
    185
    -//
    
    186
    -//        assertValidateResultForDtoType(resultByType, TripSeineDto.class, 2);
    
    187
    -//        assertValidateResultForDtoType(resultByType, RouteDto.class, 80);
    
    188
    -//        assertValidateResultForDtoType(resultByType, ActivitySeineDto.class, 1519);
    
    189
    -//        assertValidateResultForDtoType(resultByType, FloatingObjectDto.class, 99);
    
    190
    -//        assertValidateResultForDtoType(resultByType, SetSeineDto.class, 77);
    
    191
    -
    
    192
    -    }
    
    193
    -
    
    194
    -    @Test
    
    195
    -    public void testValidateTripSeinesUdpate() throws Exception {
    
    196
    -
    
    197
    -        DataValidationRequest request = new DataValidationRequest();
    
    198
    -
    
    199
    -        request.setValidationContext(ValidateService.UPDATE_VALIDATION_CONTEXT);
    
    200
    -        request.setScopes(ImmutableSet.copyOf(NuitonValidatorScope.values()));
    
    201
    -        request.setDataIds(ImmutableSet.of(ObserveFixtures.TRIP_SEINE_ID_1, ObserveFixtures.TRIP_SEINE_ID_2));
    
    202
    -
    
    203
    -        ValidationResult<DataValidationRequest> result = service.validateData(request);
    
    204
    -        Assert.assertNotNull(result);
    
    205
    -        //FIXME
    
    206
    -
    
    207
    -//        ImmutableMap<Class<? extends IdDto>, ValidateResultForDtoType<? extends IdDto>> resultByType = result.getResultByType();
    
    208
    -//        Assert.assertNotNull(resultByType);
    
    209
    -//        Assert.assertEquals(8, resultByType.size());
    
    210
    -//
    
    211
    -//        assertValidateResultForDtoType(resultByType, TripSeineDto.class, 2);
    
    212
    -//        assertValidateResultForDtoType(resultByType, RouteDto.class, 80);
    
    213
    -//        assertValidateResultForDtoType(resultByType, ActivitySeineDto.class, 1519);
    
    214
    -//        assertValidateResultForDtoType(resultByType, FloatingObjectDto.class, 99);
    
    215
    -//        assertValidateResultForDtoType(resultByType, TransmittingBuoyDto.class, 42);
    
    216
    -//        assertValidateResultForDtoType(resultByType, SetSeineDto.class, 77);
    
    217
    -//        assertValidateResultForDtoType(resultByType, NonTargetCatchDto.class, 3);
    
    218
    -//        assertValidateResultForDtoType(resultByType, SchoolEstimateDto.class, 27);
    
    219
    -
    
    220
    -    }
    
    221
    -
    
    222
    -//    protected <D extends ReferentialDto> void assertValidateResultForReferentialDtoType(ImmutableMap<Class<? extends ReferentialDto>, ValidateResultForDtoType<? extends IdDto>> resultByType, Class<D> dtoType, int expectedCount) {
    
    223
    -//
    
    224
    -//        ValidateResultForDtoType<D> validateResultForDtoType = (ValidateResultForDtoType) resultByType.get(dtoType);
    
    225
    -//        Assert.assertNotNull(validateResultForDtoType);
    
    226
    -//        ImmutableSet<ValidateResultForDto<D>> validateResultForDtos = validateResultForDtoType.getValidateResultForDto();
    
    227
    -//        Assert.assertNotNull(validateResultForDtos);
    
    228
    -//        Assert.assertEquals(expectedCount, validateResultForDtos.size());
    
    229
    -//        for (ValidateResultForDto<D> validateResultForDto : validateResultForDtos) {
    
    230
    -//            Assert.assertNotNull(validateResultForDto.getMessages());
    
    231
    -//            Assert.assertFalse(validateResultForDto.getMessages().isEmpty());
    
    232
    -//        }
    
    233
    -//
    
    234
    -//    }
    
    235
    -
    
    236
    -//    protected <D extends IdDto> void assertValidateResultForDtoType(ImmutableMap<Class<? extends IdDto>, ValidateResultForDtoType<? extends IdDto>> resultByType, Class<D> dtoType, int expectedCount) {
    
    237
    -//
    
    238
    -//        ValidateResultForDtoType<D> validateResultForDtoType = (ValidateResultForDtoType) resultByType.get(dtoType);
    
    239
    -//        Assert.assertNotNull(validateResultForDtoType);
    
    240
    -//        ImmutableSet<ValidateResultForDto<D>> validateResultForDtos = validateResultForDtoType.getValidateResultForDto();
    
    241
    -//        Assert.assertNotNull(validateResultForDtos);
    
    242
    -//        Assert.assertEquals(expectedCount, validateResultForDtos.size());
    
    243
    -//        for (ValidateResultForDto<D> validateResultForDto : validateResultForDtos) {
    
    244
    -//            Assert.assertNotNull(validateResultForDto.getMessages());
    
    245
    -//            Assert.assertFalse(validateResultForDto.getMessages().isEmpty());
    
    246
    -//        }
    
    247
    -//
    
    248
    -//    }
    
    249
    -
    
    250
    -}

  • services-client/src/test/java/fr/ird/observe/services/client/service/seine/TripSeineServiceClientTest.java deleted
    1
    -package fr.ird.observe.services.client.service.seine;
    
    2
    -
    
    3
    -/*
    
    4
    - * #%L
    
    5
    - * ObServe :: Services client implementation
    
    6
    - * %%
    
    7
    - * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io
    
    8
    - * %%
    
    9
    - * This program is free software: you can redistribute it and/or modify
    
    10
    - * it under the terms of the GNU General Public License as
    
    11
    - * published by the Free Software Foundation, either version 3 of the
    
    12
    - * License, or (at your option) any later version.
    
    13
    - * 
    
    14
    - * This program is distributed in the hope that it will be useful,
    
    15
    - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    - * GNU General Public License for more details.
    
    18
    - * 
    
    19
    - * You should have received a copy of the GNU General Public
    
    20
    - * License along with this program.  If not, see
    
    21
    - * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    - * #L%
    
    23
    - */
    
    24
    -
    
    25
    -import com.google.common.collect.Iterables;
    
    26
    -import fr.ird.observe.dto.data.seine.TripSeineDto;
    
    27
    -import fr.ird.observe.dto.data.seine.TripSeineReference;
    
    28
    -import fr.ird.observe.dto.form.Form;
    
    29
    -import fr.ird.observe.dto.reference.DataDtoReference;
    
    30
    -import fr.ird.observe.dto.reference.DataDtoReferenceSet;
    
    31
    -import fr.ird.observe.dto.referential.HarbourDto;
    
    32
    -import fr.ird.observe.dto.referential.OceanDto;
    
    33
    -import fr.ird.observe.dto.referential.PersonDto;
    
    34
    -import fr.ird.observe.dto.referential.ProgramDto;
    
    35
    -import fr.ird.observe.dto.referential.VesselDto;
    
    36
    -import fr.ird.observe.services.action.DeleteRequestDto;
    
    37
    -import fr.ird.observe.services.action.LoadFormRequestDto;
    
    38
    -import fr.ird.observe.services.action.PreCreateFormRequestDto;
    
    39
    -import fr.ird.observe.services.action.SaveRequestDto;
    
    40
    -import fr.ird.observe.services.client.service.ServiceClientTestSupport;
    
    41
    -import fr.ird.observe.services.service.data.seine.TripSeineService;
    
    42
    -import fr.ird.observe.test.ObserveFixtures;
    
    43
    -import org.junit.Assert;
    
    44
    -import org.junit.Ignore;
    
    45
    -import org.junit.Test;
    
    46
    -import org.nuiton.util.DateUtil;
    
    47
    -
    
    48
    -/**
    
    49
    - * @author Tony Chemit - dev@tchemit.fr
    
    50
    - */
    
    51
    -
    
    52
    -public class TripSeineServiceClientTest extends ServiceClientTestSupport {
    
    53
    -
    
    54
    -    protected TripSeineService service;
    
    55
    -
    
    56
    -    @Override
    
    57
    -    public void setUp() throws Exception {
    
    58
    -        super.setUp();
    
    59
    -
    
    60
    -        service = newService(TripSeineService.class);
    
    61
    -    }
    
    62
    -
    
    63
    -    @Test
    
    64
    -    public void loadFormTest() throws Exception {
    
    65
    -
    
    66
    -        Form<TripSeineDto> form = service.loadForm(LoadFormRequestDto.of(ObserveFixtures.TRIP_SEINE_ID_1));
    
    67
    -
    
    68
    -        Assert.assertNotNull(form);
    
    69
    -        TripSeineDto tripSeineDto = form.getObject();
    
    70
    -
    
    71
    -        Assert.assertNull(tripSeineDto.getCaptain());
    
    72
    -
    
    73
    -        Assert.assertEquals("fr.ird.observe.entities.referentiel.Person#1355399844272#0.32586441962131485", tripSeineDto.getObserver().getId());
    
    74
    -        Assert.assertEquals("Fanchon", tripSeineDto.getObserver().getFirstName());
    
    75
    -        Assert.assertEquals("Varenne", tripSeineDto.getObserver().getLastName());
    
    76
    -        Assert.assertNull(tripSeineDto.getDataEntryOperator());
    
    77
    -        Assert.assertEquals("fr.ird.observe.entities.referentiel.Vessel#1306847717532#0.7435948873477364", tripSeineDto.getVessel().getId());
    
    78
    -        Assert.assertEquals("835", tripSeineDto.getVessel().getCode());
    
    79
    -        Assert.assertEquals("BERNICA", tripSeineDto.getVessel().getLabel());
    
    80
    -        Assert.assertEquals("fr.ird.observe.entities.referentiel.Ocean#1239832686152#0.8325731048817705", tripSeineDto.getOcean().getId());
    
    81
    -        Assert.assertEquals("2", tripSeineDto.getOcean().getCode());
    
    82
    -        Assert.assertEquals("Indien", tripSeineDto.getOcean().getLabel());
    
    83
    -        Assert.assertNull(tripSeineDto.getDepartureHarbour());
    
    84
    -        Assert.assertNull(tripSeineDto.getLandingHarbour());
    
    85
    -        Assert.assertNull(tripSeineDto.getErsId());
    
    86
    -        Assert.assertEquals(DateUtil.createDate(25, 1, 2013), tripSeineDto.getStartDate());
    
    87
    -        Assert.assertEquals(DateUtil.createDate(27, 2, 2013), tripSeineDto.getEndDate());
    
    88
    -        Assert.assertNull(tripSeineDto.getFormsUrl());
    
    89
    -        Assert.assertNull(tripSeineDto.getReportsUrl());
    
    90
    -        Assert.assertTrue(tripSeineDto.getComment().startsWith("Caractéristiques de la senne"));
    
    91
    -
    
    92
    -        assertEditLabels(form, 8,
    
    93
    -                         ProgramDto.class,
    
    94
    -                         PersonDto.class,
    
    95
    -                         VesselDto.class,
    
    96
    -                         OceanDto.class,
    
    97
    -                         HarbourDto.class);
    
    98
    -
    
    99
    -    }
    
    100
    -
    
    101
    -    @Test
    
    102
    -    public void preCreateTest() {
    
    103
    -        Form<TripSeineDto> form = service.preCreate(PreCreateFormRequestDto.of(ObserveFixtures.PROGRAM_ID));
    
    104
    -
    
    105
    -        Assert.assertNotNull(form);
    
    106
    -        TripSeineDto tripSeineDto = form.getObject();
    
    107
    -
    
    108
    -        Assert.assertNull(tripSeineDto.getCaptain());
    
    109
    -        Assert.assertNull(tripSeineDto.getObserver());
    
    110
    -        Assert.assertNull(tripSeineDto.getDataEntryOperator());
    
    111
    -        Assert.assertNull(tripSeineDto.getVessel());
    
    112
    -        Assert.assertNull(tripSeineDto.getOcean());
    
    113
    -        Assert.assertNull(tripSeineDto.getDepartureHarbour());
    
    114
    -        Assert.assertNull(tripSeineDto.getLandingHarbour());
    
    115
    -        Assert.assertNull(tripSeineDto.getErsId());
    
    116
    -        //Assert.assertEquals(DateUtil.getDay(ObserveServiceContextTopiaTaiste.DATE), tripSeineDto.getStartDate());
    
    117
    -        //Assert.assertEquals(DateUtil.getDay(ObserveServiceContextTopiaTaiste.DATE), tripSeineDto.getEndDate());
    
    118
    -        Assert.assertNull(tripSeineDto.getFormsUrl());
    
    119
    -        Assert.assertNull(tripSeineDto.getReportsUrl());
    
    120
    -        Assert.assertNull(tripSeineDto.getComment());
    
    121
    -
    
    122
    -        assertEditLabels(form, 8,
    
    123
    -                         ProgramDto.class,
    
    124
    -                         PersonDto.class,
    
    125
    -                         VesselDto.class,
    
    126
    -                         OceanDto.class,
    
    127
    -                         HarbourDto.class);
    
    128
    -
    
    129
    -    }
    
    130
    -
    
    131
    -    //FIXME Ce test modifie la base, il faut trouver un moyen d'utiliser une autre base
    
    132
    -    @Ignore
    
    133
    -    @Test
    
    134
    -    public void saveUpdateTest() {
    
    135
    -
    
    136
    -        Form<TripSeineDto> form = service.loadForm(LoadFormRequestDto.of(ObserveFixtures.TRIP_SEINE_ID_1));
    
    137
    -
    
    138
    -        TripSeineDto tripSeineDto = form.getObject();
    
    139
    -
    
    140
    -//        ReferenceSetDto<PersonDto> personRefs = formDto.getReferenceSetDto(PersonDto.class);
    
    141
    -//        ReferenceSetDto<OceanDto> oceanRefs = formDto.getReferenceSetDto(OceanDto.class);
    
    142
    -//        ReferenceSetDto<HarbourDto> harbourRefs = formDto.getReferenceSetDto(HarbourDto.class);
    
    143
    -//
    
    144
    -//        tripSeineDto.setCaptain((PersonReference) personRefs.toSet(0));
    
    145
    -//        tripSeineDto.setDataEntryOperator((PersonReference) personRefs.toSet(2));
    
    146
    -//
    
    147
    -//        tripSeineDto.setOcean((OceanReference) oceanRefs.toSet(0));
    
    148
    -//
    
    149
    -//        tripSeineDto.setDepartureHarbour((HarbourReference) harbourRefs.toSet(0));
    
    150
    -//        tripSeineDto.setLandingHarbour((HarbourReference) harbourRefs.toSet(1));
    
    151
    -
    
    152
    -        tripSeineDto.setErsId("ersid");
    
    153
    -
    
    154
    -        tripSeineDto.setStartDate(DateUtil.createDate(24, 8, 2015));
    
    155
    -        tripSeineDto.setEndDate(DateUtil.createDate(24, 9, 2015));
    
    156
    -
    
    157
    -        tripSeineDto.setFormsUrl("http://une.url.com/formulaire");
    
    158
    -        tripSeineDto.setReportsUrl("http://une.url.com/rapport");
    
    159
    -
    
    160
    -        tripSeineDto.setComment("Un commentaire");
    
    161
    -
    
    162
    -        service.save(SaveRequestDto.of(form.getObject()));
    
    163
    -
    
    164
    -        Form<TripSeineDto> formReload = service.loadForm(LoadFormRequestDto.of(ObserveFixtures.TRIP_SEINE_ID_1));
    
    165
    -        TripSeineDto tripSeineDtoReload = formReload.getObject();
    
    166
    -
    
    167
    -        Assert.assertEquals(tripSeineDto.getCaptain().getId(), tripSeineDtoReload.getCaptain().getId());
    
    168
    -        Assert.assertEquals(tripSeineDto.getObserver().getId(), tripSeineDtoReload.getObserver().getId());
    
    169
    -        Assert.assertEquals(tripSeineDto.getDataEntryOperator().getId(), tripSeineDtoReload.getDataEntryOperator().getId());
    
    170
    -        Assert.assertEquals(tripSeineDto.getVessel().getId(), tripSeineDtoReload.getVessel().getId());
    
    171
    -        Assert.assertEquals(tripSeineDto.getOcean().getId(), tripSeineDtoReload.getOcean().getId());
    
    172
    -        Assert.assertEquals(tripSeineDto.getDepartureHarbour().getId(), tripSeineDtoReload.getDepartureHarbour().getId());
    
    173
    -        Assert.assertEquals(tripSeineDto.getLandingHarbour().getId(), tripSeineDtoReload.getLandingHarbour().getId());
    
    174
    -        Assert.assertEquals(tripSeineDto.getErsId(), tripSeineDtoReload.getErsId());
    
    175
    -        Assert.assertEquals(tripSeineDto.getStartDate(), tripSeineDtoReload.getStartDate());
    
    176
    -        Assert.assertEquals(tripSeineDto.getEndDate(), tripSeineDtoReload.getEndDate());
    
    177
    -        Assert.assertEquals(tripSeineDto.getFormsUrl(), tripSeineDtoReload.getFormsUrl());
    
    178
    -        Assert.assertEquals(tripSeineDto.getReportsUrl(), tripSeineDtoReload.getReportsUrl());
    
    179
    -        Assert.assertEquals(tripSeineDto.getComment(), tripSeineDtoReload.getComment());
    
    180
    -
    
    181
    -    }
    
    182
    -
    
    183
    -    @Ignore
    
    184
    -    @Test
    
    185
    -    public void deleteTest() {
    
    186
    -
    
    187
    -        service.delete(DeleteRequestDto.of(ObserveFixtures.TRIP_SEINE_ID_1));
    
    188
    -
    
    189
    -        DataDtoReferenceSet<TripSeineReference> tripSeineByProgram = service.getAllTripSeine();
    
    190
    -
    
    191
    -        Assert.assertEquals(2, tripSeineByProgram.size());
    
    192
    -
    
    193
    -        Assert.assertTrue(Iterables.isEmpty(DataDtoReference.filterById(tripSeineByProgram.toSet(), ObserveFixtures.TRIP_SEINE_ID_1)));
    
    194
    -
    
    195
    -    }
    
    196
    -
    
    197
    -
    
    198
    -}