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.mybmw.internal.handler.backend;
15 import static org.junit.jupiter.api.Assertions.assertEquals;
16 import static org.junit.jupiter.api.Assertions.assertFalse;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.junit.jupiter.api.Test;
20 import org.openhab.binding.mybmw.internal.util.FileReader;
24 * checks if the response anonymization is successful
26 * @author Martin Grassl - initial contribution
29 public class ResponseContentAnonymizerTest {
31 void testAnonymizeResponseContent() {
32 String content = FileReader.fileToString("responses/vehicles.json");
33 String anonymous = ResponseContentAnonymizer.anonymizeResponseContent(content);
34 assertFalse(anonymous.contains("VIN1234567"), "VIN not deleted!");
35 assertFalse(anonymous.contains("Testort"), "Location not deleted!");
39 void testAnonymizeRandomString() {
40 String content = "asdfiulsahföauifhnasdölfam,xöasiocjfsailfunsalifnsaölfkmasdäf.ifnvaskdfnvinlocationasdfiulsdanf";
41 String anonymous = ResponseContentAnonymizer.anonymizeResponseContent(content);
42 assertEquals(content, anonymous);
46 void testAnonymizeEmptyString() {
48 String anonymous = ResponseContentAnonymizer.anonymizeResponseContent(content);
49 assertEquals(content, anonymous);
53 void testAnonymizeNullString() {
54 String content = null;
55 String anonymous = ResponseContentAnonymizer.anonymizeResponseContent(content);
56 assertEquals("", anonymous);