Skip to content

Commit

Permalink
Add tests about mandatory or optional content format.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernard31 committed Jun 3, 2021
1 parent bab1cfb commit f15debb
Showing 1 changed file with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*******************************************************************************
* Copyright (c) 2021 Sierra Wireless and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v20.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.html.
*
* Contributors:
* Sierra Wireless - initial API and implementation
*******************************************************************************/
package org.eclipse.leshan.core.request;

import static org.eclipse.leshan.core.request.ContentFormat.*;
import static org.junit.Assert.assertEquals;

import java.util.Arrays;
import java.util.List;

import org.eclipse.leshan.core.LwM2m.Version;
import org.eclipse.leshan.core.node.codec.CodecException;
import org.junit.Test;

public class ContentFormatTest {

@Test
public void get_optional_content_format_for_v1_0() throws CodecException {

List<ContentFormat> optionalContentFormat = ContentFormat
.getOptionalContentFormatForClient(Arrays.asList(TLV, JSON, TEXT, OPAQUE), Version.V1_0);

assertEquals(Arrays.asList(JSON, TEXT, OPAQUE), optionalContentFormat);
}

@Test
public void get_optional_content_format_for_v1_1() throws CodecException {
List<ContentFormat> optionalContentFormat = ContentFormat.getOptionalContentFormatForClient(
Arrays.asList(TLV, JSON, SENML_JSON, SENML_CBOR, TEXT, OPAQUE, CBOR, LINK), Version.V1_1);

assertEquals(Arrays.asList(TLV, JSON, SENML_JSON, SENML_CBOR, CBOR), optionalContentFormat);

}
}

0 comments on commit f15debb

Please sign in to comment.