Skip to content

Commit

Permalink
Registry: ObjectMapperTest
Browse files Browse the repository at this point in the history
  • Loading branch information
oalagtash committed Jun 18, 2024
1 parent 7904300 commit 68bd2d2
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.eclipse.digitaltwin.basyx.aasregistry.service.tests;

import static org.assertj.core.api.Assertions.assertThat;

import java.util.Collections;

import org.eclipse.digitaltwin.basyx.aasregistry.client.ApiClient;
import org.eclipse.digitaltwin.basyx.aasregistry.client.model.AssetAdministrationShellDescriptor;
import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

public class ObjectMapperTest {

@Test
void emptyCollection_excludedFromJson() {
ApiClient apiClient = new ApiClient();
ObjectMapper objectMapper = apiClient.getObjectMapper();
AssetAdministrationShellDescriptor descr = new AssetAdministrationShellDescriptor();
descr.id("descriptor_with_empty_list");
descr.description(Collections.emptyList());

JsonNode jsonNode = objectMapper.valueToTree(descr);
JsonNode description = jsonNode.get("description");

assertThat(description).isNull();
}

}

0 comments on commit 68bd2d2

Please sign in to comment.