2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.windcentrale.internal.dto;
15 import static org.hamcrest.CoreMatchers.*;
16 import static org.hamcrest.MatcherAssert.assertThat;
18 import java.util.Arrays;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.junit.jupiter.api.Test;
24 * Tests the {@link Windmill} enum.
26 * @author Wouter Born - Initial contribution
29 public class WindmillTest {
32 public void fromName() {
33 assertThat(Windmill.fromName("Unknown Windmill"), nullValue());
34 assertThat(Windmill.fromName("De Grote Geert"), is(Windmill.DE_GROTE_GEERT));
36 for (Windmill windmill : Windmill.values()) {
37 assertThat(Windmill.fromName(windmill.getName()), is(windmill));
42 public void fromProjectCode() {
43 assertThat(Windmill.fromProjectCode("WND-UNKNOWN"), nullValue());
44 assertThat(Windmill.fromProjectCode("WND-GG"), is(Windmill.DE_GROTE_GEERT));
46 for (Windmill windmill : Windmill.values()) {
47 assertThat(Windmill.fromProjectCode(windmill.getProjectCode()), is(windmill));
52 public void namesAreUnique() {
53 int count = (int) Arrays.stream(Windmill.values()) //
54 .map(Windmill::getName) //
58 assertThat(count, is(Windmill.values().length));
62 public void projectCodesAreUnique() {
63 int count = (int) Arrays.stream(Windmill.values()) //
64 .map(Windmill::getProjectCode) //
68 assertThat(count, is(Windmill.values().length));