Changeset 625


Ignore:
Timestamp:
Apr 10, 2012, 2:38:39 PM (5 years ago)
Author:
david.vanenckevort@…
Message:
  • Updated schema with constraints.
  • Added tests for history and language service.
  • Renamed common context xml to make it clearer that it is common to the tests.
  • Changed language table to be consistent with the other tables
  • Added validation to the history service.
Location:
trunk/code/conceptwiki/service/service-impl/src
Files:
2 added
5 edited
2 copied
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/code/conceptwiki/service/service-impl/src/main/java/nl/nbic/conceptwiki/service/impl/HistoryServiceImpl.java

    r431 r625  
    55import nl.nbic.conceptwiki.common.api.Changeset;
    66import nl.nbic.conceptwiki.common.jsr303.annotation.MethodValidation;
     7import nl.nbic.conceptwiki.common.util.ValidationUtility;
    78import nl.nbic.conceptwiki.service.ChangesetSerializer;
    89import nl.nbic.conceptwiki.service.api.HistoryService;
     
    1920@MethodValidation
    2021public class HistoryServiceImpl implements HistoryService {
     22    @Inject
     23    ValidationUtility validationUtility;
    2124    /**
    2225     * Spring JDBC utility class.
     
    4750    @Transactional("jdbc")
    4851    public void storeRevision(final String uuid, final Changeset changeset) {
     52        validationUtility.validateUuid(uuid);
     53        validationUtility.validateChangeset(changeset);
    4954        final String serializedChangeset = changesetSerializer.serialize(changeset);
    5055        final Object[] params = constructParams(1, uuid, serializedChangeset);
  • trunk/code/conceptwiki/service/service-impl/src/main/java/nl/nbic/conceptwiki/service/impl/LanguageServiceImpl.java

    r436 r625  
    3333    @Override
    3434    public Language getLanguage(final String code) {
    35         final List<Language> languages = jdbcTemplate.query("SELECT * FROM language WHERE code = ?",
     35        final List<Language> languages = jdbcTemplate.query("SELECT * FROM languages WHERE code = ?",
    3636                new Object[]{code}, new RowMapper<Language>() {
    3737                    @Override
  • trunk/code/conceptwiki/service/service-impl/src/test/java/nl/nbic/conceptwiki/service/BranchServiceImplTest.java

    r623 r625  
    2626 */
    2727@RunWith(SpringJUnit4ClassRunner.class)
    28 @ContextConfiguration({"service-impl-test-context.xml","branch-service-tests.xml"})
     28@ContextConfiguration({"common-test-context.xml","branch-service-tests.xml"})
    2929@Transactional
    3030public class BranchServiceImplTest {
     
    3737     * Name of the branch.
    3838     */
    39     public static final String TEST_BRANCH = "Community";
     39    public static final String TEST_BRANCH = "Test branch";
    4040
    4141    /**
     
    6262    @Test
    6363    public void testGetBranch() {
    64         final Branch testBranch = new BranchImpl(1, TEST_BRANCH);
     64        final Branch testBranch = new BranchImpl(1, "Community");
    6565
    6666        final Branch result = branchServiceImpl.getBranch(1);
     
    7777
    7878        final int before = branchServiceImpl.getBranchCount();
    79         branchServiceImpl.createBranch("Bla");
     79        branchServiceImpl.createBranch(TEST_BRANCH);
    8080        final int after = branchServiceImpl.getBranchCount();
    8181       
  • trunk/code/conceptwiki/service/service-impl/src/test/resources/nl/nbic/conceptwiki/service/branch-service-tests.xml

    r623 r625  
    55
    66       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    7           http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/context/spring-context-2.5.xsd/spring-spring-context-2.5.xsd-3.0.xsd
    8 ">
     7          http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/context/spring-context-2.5.xsd/spring-spring-context-2.5.xsd-3.0.xsd"
     8       default-init-method="init" default-destroy-method="destroy">
    99
    1010    <bean id="branchService" class="nl.nbic.conceptwiki.service.impl.BranchServiceImpl"/>
  • trunk/code/conceptwiki/service/service-impl/src/test/resources/nl/nbic/conceptwiki/service/common-test-context.xml

    r623 r625  
    88                http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
    99        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
    10         http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd">
     10        http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd"
     11       default-init-method="init" default-destroy-method="destroy">
    1112       
    1213        <!--
     
    1819        -->
    1920    <jdbc:embedded-database id="dataSource" type="H2">
    20         <jdbc:script location="classpath:/nl/nbic/conceptwiki/service/schema.sql"/>
     21        <jdbc:script location="classpath:/nl/nbic/conceptwiki/service/schema-h2.sql"/>
    2122        <jdbc:script location="classpath:/nl/nbic/conceptwiki/service/test-data.sql"/>
    2223    </jdbc:embedded-database>
     
    2728        </constructor-arg>
    2829    </bean>
    29     <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
     30   
     31    <bean id="transactionManager" name="jdbc" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    3032        <property name="dataSource" ref="dataSource" />
    3133    </bean>
     34   
     35    <bean id="validationUtility" class="nl.nbic.conceptwiki.common.util.impl.ValidationUtilityImpl" />
    3236</beans>
  • trunk/code/conceptwiki/service/service-impl/src/test/resources/nl/nbic/conceptwiki/service/history-service-tests.xml

    r623 r625  
    33       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    44       xmlns:context="http://www.springframework.org/schema/context/spring-context-2.5.xsd"
    5 
    65       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    7           http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/context/spring-context-2.5.xsd/spring-spring-context-2.5.xsd-3.0.xsd
    8 ">
    9 
    10     <bean id="branchService" class="nl.nbic.conceptwiki.service.impl.BranchServiceImpl"/>
    11 
     6          http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/context/spring-context-2.5.xsd/spring-spring-context-2.5.xsd-3.0.xsd"
     7       default-init-method="init" default-destroy-method="destroy">
     8    <bean id="changesetSerializer" class="nl.nbic.conceptwiki.service.impl.ChangesetSerializerImpl"/>
     9    <bean id="historyService" class="nl.nbic.conceptwiki.service.impl.HistoryServiceImpl"/>
    1210</beans>
  • trunk/code/conceptwiki/service/service-impl/src/test/resources/nl/nbic/conceptwiki/service/language-service-tests.xml

    r623 r625  
    55
    66       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    7           http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/context/spring-context-2.5.xsd/spring-spring-context-2.5.xsd-3.0.xsd
    8 ">
     7          http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/context/spring-context-2.5.xsd/spring-spring-context-2.5.xsd-3.0.xsd"
     8       default-init-method="init" default-destroy-method="destroy">
    99
    10     <bean id="branchService" class="nl.nbic.conceptwiki.service.impl.BranchServiceImpl"/>
    11 
     10    <bean id="languageService" class="nl.nbic.conceptwiki.service.impl.LanguageServiceImpl"/>
    1211</beans>
  • trunk/code/conceptwiki/service/service-impl/src/test/resources/nl/nbic/conceptwiki/service/schema-h2.sql

    r624 r625  
    1 CREATE TABLE IF NOT EXISTS branches (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(64) NOT NULL);
     1CREATE TABLE IF NOT EXISTS branches (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(64) NOT NULL, PRIMARY KEY (id), UNIQUE(name));
    22CREATE TABLE IF NOT EXISTS revisions (transaction_id INT NOT NULL, uuid UUID NOT NULL, changeset CLOB NOT NULL);
    3 CREATE TABLE IF NOT EXISTS languages (code CHAR(3) NOT NULL);
     3CREATE TABLE IF NOT EXISTS languages (code CHAR(3) NOT NULL, PRIMARY KEY(code));
  • trunk/code/conceptwiki/service/service-impl/src/test/resources/nl/nbic/conceptwiki/service/test-data.sql

    r624 r625  
     1DELETE FROM branches;
    12INSERT INTO branches(id, name) VALUES(1, 'Community');
    23INSERT INTO branches(id, name) VALUES(2, 'UMLS');
    34INSERT INTO branches(id, name) VALUES(3, 'SwissProt');
    45
     6DELETE FROM languages;
    57INSERT INTO languages(code) VALUES('en');
    68INSERT INTO languages(code) VALUES('nl');
Note: See TracChangeset for help on using the changeset viewer.