// Path: json-unit-core/src/main/java/net/javacrumbs/jsonunit/core/internal/ClassUtils.java
// static boolean isClassPresent(String className) {
//     try {
//         ClassUtils.class.getClassLoader().loadClass(className);
//         return true;
//     } catch (Throwable e) {
//         return false;
//     }
// }
// 
// Path: json-unit-core/src/main/java/net/javacrumbs/jsonunit/core/internal/Converter.java
// static final String LIBRARIES_PROPERTY_NAME = "json-unit.libraries";


import com.fasterxml.jackson.databind.node.BooleanNode;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collections;
import static net.javacrumbs.jsonunit.core.internal.ClassUtils.isClassPresent;
import static net.javacrumbs.jsonunit.core.internal.Converter.LIBRARIES_PROPERTY_NAME;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
    void shouldUseOnlyFactorySpecifiedBySystemProperty() {
        System.setProperty(LIBRARIES_PROPERTY_NAME,"gson");
        Converter converter = Converter.createDefaultConverter();
        assertThat(converter.getFactories()).extracting("class").containsExactly(GsonNodeFactory.class);
        System.setProperty(LIBRARIES_PROPERTY_NAME, "");
    }

    @Test
    void shouldChangeOrderSpecifiedBySystemProperty() {
        System.setProperty(LIBRARIES_PROPERTY_NAME,"jackson2, gson ,json.org");
        Converter converter = Converter.createDefaultConverter();
        assertThat(converter.getFactories()).extracting("class").containsExactly(Jackson2NodeFactory.class, GsonNodeFactory.class, JsonOrgNodeFactory.class);
        System.setProperty(LIBRARIES_PROPERTY_NAME, "");
    }

    @Test
    void shouldFailOnUnknownFactory() {
        System.setProperty(LIBRARIES_PROPERTY_NAME,"unknown");
        try {
            Converter.createDefaultConverter();
            fail("Exception expected");
        } catch (IllegalArgumentException e) {
            assertThat(e.getMessage()).isEqualTo("'unknown' library name not recognized.");
        } finally {
            System.setProperty(LIBRARIES_PROPERTY_NAME, "");
        }
    }

    @Test
    void classShouldBePresent() {
// Path: json-unit-core/src/main/java/net/javacrumbs/jsonunit/core/internal/ClassUtils.java
// static boolean isClassPresent(String className) {
//     try {
//         ClassUtils.class.getClassLoader().loadClass(className);
//         return true;
//     } catch (Throwable e) {
//         return false;
//     }
// }
// 
// Path: json-unit-core/src/main/java/net/javacrumbs/jsonunit/core/internal/Converter.java
// static final String LIBRARIES_PROPERTY_NAME = "json-unit.libraries";


// Path: json-unit-core/src/test/java/net/javacrumbs/jsonunit/core/internal/ConverterTest.java
import com.fasterxml.jackson.databind.node.BooleanNode;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collections;
import static net.javacrumbs.jsonunit.core.internal.ClassUtils.isClassPresent;
import static net.javacrumbs.jsonunit.core.internal.Converter.LIBRARIES_PROPERTY_NAME;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

    void shouldUseOnlyFactorySpecifiedBySystemProperty() {
        System.setProperty(LIBRARIES_PROPERTY_NAME,"gson");
        Converter converter = Converter.createDefaultConverter();
        assertThat(converter.getFactories()).extracting("class").containsExactly(GsonNodeFactory.class);
        System.setProperty(LIBRARIES_PROPERTY_NAME, "");
    }

    @Test
    void shouldChangeOrderSpecifiedBySystemProperty() {
        System.setProperty(LIBRARIES_PROPERTY_NAME,"jackson2, gson ,json.org");
        Converter converter = Converter.createDefaultConverter();
        assertThat(converter.getFactories()).extracting("class").containsExactly(Jackson2NodeFactory.class, GsonNodeFactory.class, JsonOrgNodeFactory.class);
        System.setProperty(LIBRARIES_PROPERTY_NAME, "");
    }

    @Test
    void shouldFailOnUnknownFactory() {
        System.setProperty(LIBRARIES_PROPERTY_NAME,"unknown");
        try {
            Converter.createDefaultConverter();
            fail("Exception expected");
        } catch (IllegalArgumentException e) {
            assertThat(e.getMessage()).isEqualTo("'unknown' library name not recognized.");
        } finally {
            System.setProperty(LIBRARIES_PROPERTY_NAME, "");
        }
    }

    @Test
    void classShouldBePresent() {
        assertTrue(isClassPresent("java.lang.String"));