View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.core.persistence.jpa.inner;
20  
21  import static org.junit.jupiter.api.Assertions.assertEquals;
22  import static org.junit.jupiter.api.Assertions.assertFalse;
23  import static org.junit.jupiter.api.Assertions.assertNotNull;
24  
25  import java.util.List;
26  import org.apache.syncope.common.lib.types.IdMImplementationType;
27  import org.apache.syncope.common.lib.types.IdRepoImplementationType;
28  import org.apache.syncope.common.lib.types.ImplementationEngine;
29  import org.apache.syncope.core.persistence.api.dao.ImplementationDAO;
30  import org.apache.syncope.core.persistence.api.entity.Implementation;
31  import org.apache.syncope.core.persistence.jpa.AbstractTest;
32  import org.junit.jupiter.api.Test;
33  import org.springframework.beans.factory.annotation.Autowired;
34  import org.springframework.transaction.annotation.Transactional;
35  
36  @Transactional("Master")
37  public class ImplementationTest extends AbstractTest {
38  
39      @Autowired
40      private ImplementationDAO implementationDAO;
41  
42      @Test
43      public void findAll() {
44          List<Implementation> implementations = implementationDAO.findAll();
45          assertFalse(implementations.isEmpty());
46  
47          assertEquals(19, implementations.size());
48  
49          implementations = implementationDAO.findByType(IdMImplementationType.PULL_ACTIONS);
50          assertEquals(1, implementations.size());
51  
52          implementations = implementationDAO.findByType(IdMImplementationType.PROPAGATION_ACTIONS);
53          assertEquals(2, implementations.size());
54  
55          implementations = implementationDAO.findByType(IdRepoImplementationType.TASKJOB_DELEGATE);
56          assertEquals(6, implementations.size());
57  
58          implementations = implementationDAO.findByType(IdRepoImplementationType.REPORT_DELEGATE);
59          assertEquals(1, implementations.size());
60  
61          implementations = implementationDAO.findByType(IdRepoImplementationType.ACCOUNT_RULE);
62          assertEquals(2, implementations.size());
63  
64          implementations = implementationDAO.findByType(IdRepoImplementationType.PASSWORD_RULE);
65          assertEquals(3, implementations.size());
66  
67          implementations = implementationDAO.findByType(IdRepoImplementationType.VALIDATOR);
68          assertEquals(2, implementations.size());
69  
70          implementations = implementationDAO.findByType(IdMImplementationType.PULL_CORRELATION_RULE);
71          assertEquals(1, implementations.size());
72  
73          implementations = implementationDAO.findByType(IdMImplementationType.PUSH_CORRELATION_RULE);
74          assertEquals(1, implementations.size());
75      }
76  
77      @Test
78      public void create() {
79          Implementation impl = entityFactory.newEntity(Implementation.class);
80          impl.setKey("new");
81          impl.setEngine(ImplementationEngine.GROOVY);
82          impl.setType(IdRepoImplementationType.VALIDATOR);
83          impl.setBody("");
84  
85          Implementation actual = implementationDAO.save(impl);
86          assertNotNull(actual);
87          assertEquals(impl, actual);
88      }
89  }