]> git.basschouten.com Git - openhab-addons.git/blob
d6b2418fc4849ef3329ce963eb7e9839afccfa06
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.persistence.jdbc.internal;
14
15 import static org.junit.jupiter.api.Assertions.assertThrows;
16 import static org.mockito.Mockito.mock;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.junit.jupiter.api.BeforeEach;
20 import org.junit.jupiter.api.Test;
21 import org.openhab.core.i18n.TimeZoneProvider;
22 import org.openhab.core.items.ItemRegistry;
23 import org.openhab.core.persistence.FilterCriteria;
24
25 /**
26  * Tests the {@link JdbcPersistenceService}.
27  *
28  * @author Christoph Weitkamp - Initial contribution
29  */
30 @NonNullByDefault
31 public class JdbcPersistenceServiceTest {
32
33     private final JdbcPersistenceService jdbcPersistenceService = new JdbcPersistenceService(mock(ItemRegistry.class),
34             mock(TimeZoneProvider.class)) {
35         @Override
36         protected boolean checkDBAccessability() {
37             return true;
38         }
39     };
40     private @NonNullByDefault({}) FilterCriteria filter;
41
42     @BeforeEach
43     public void setup() {
44         filter = new FilterCriteria();
45     }
46
47     @Test
48     void removeThrowsIllegalArgumentExceptionIfItemNameOfFilterIsNull() {
49         assertThrows(IllegalArgumentException.class, () -> jdbcPersistenceService.remove(filter));
50     }
51 }