<commit_before>package org.opennms.web.rest;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.opennms.netmgt.dao.db.OpenNMSConfigurationExecutionListener;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
import org.springframework.test.context.transaction.TransactionalTestExecutionListener;


@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
    OpenNMSConfigurationExecutionListener.class,
    DependencyInjectionTestExecutionListener.class,
    DirtiesContextTestExecutionListener.class,
    TransactionalTestExecutionListener.class
})
@ContextConfiguration(locations={
        "classpath:/META-INF/opennms/component-dao.xml",
        "classpath:/META-INF/opennms/applicationContext-daemon.xml",
        "classpath:/restServiceTest.xml"
})

public class RequisitionRestServiceTest extends AbstractSpringJerseyRestTestCase {
    
    @Test
    public void testRequisition() throws Exception {
        createRequisition();
        String url = "/requisitions/pending";
        String xml = sendRequest(GET, url, 200);
        assertTrue(xml.contains("Management interface"));

        url = "/requisitions/pending/test";
        sendPut(url + "/deploy", "");
        
        url = "/requisitions/deployed/test";
        xml = sendRequest(GET, url, 200);
        assertTrue(xml.contains("date-stamp="));

        sendRequest(DELETE, url, 200);
        xml = sendRequest(GET, url, 204);
    }

    @Test
    public void testNodes() throws Exception {
        createRequisition();

        String url = "/requisitions/pending/test/nodes";

        // create a node
        sendPost(url, "<node xmlns=\"http://xmlns.opennms.org/xsd/config/model-import\" node-label=\"shoe\" parent-node-label=\"david\" foreign-id=\"1111\" />");
        
        // get list of nodes
        String xml = sendRequest(GET, url, 200);
        assertTrue(xml.contains("<node "));
        assertTrue(xml.contains("node-label="));
        assertTrue(xml.contains("count=\"2\""));
        
        // get individual node
        url = "/requisitions/pending/test/nodes/4243";
        xml = sendRequest(GET, url, 200);
        assertTrue(xml.contains("parent-node-label=\"apknd\""));
        
        // set attributes
        sendPut(url, "nodeLabel=homo+sapien");
        xml = sendRequest(GET, url, 200);
        assertTrue(xml.contains("node-label=\"homo sapien\""));

        // delete node
        xml = sendRequest(DELETE, url, 200);
        xml = sendRequest(GET, url, 204);
    }

    @Test
    public void testNodeInterfaces() throws Exception {
        createRequisition();
        
        String base = "/requisitions/pending/test/nodes/4243/interfaces";<commit_msg>fix test, now that it knows how to convert camelcase<commit_after>package org.opennms.web.rest;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.opennms.netmgt.dao.db.OpenNMSConfigurationExecutionListener;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
import org.springframework.test.context.transaction.TransactionalTestExecutionListener;


@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
    OpenNMSConfigurationExecutionListener.class,
    DependencyInjectionTestExecutionListener.class,
    DirtiesContextTestExecutionListener.class,
    TransactionalTestExecutionListener.class
})
@ContextConfiguration(locations={
        "classpath:/META-INF/opennms/component-dao.xml",
        "classpath:/META-INF/opennms/applicationContext-daemon.xml",
        "classpath:/restServiceTest.xml"
})

public class RequisitionRestServiceTest extends AbstractSpringJerseyRestTestCase {
    
    @Test
    public void testRequisition() throws Exception {
        createRequisition();
        String url = "/requisitions/pending";
        String xml = sendRequest(GET, url, 200);
        assertTrue(xml.contains("Management interface"));

        url = "/requisitions/pending/test";
        sendPut(url + "/deploy", "");
        
        url = "/requisitions/deployed/test";
        xml = sendRequest(GET, url, 200);
        assertTrue(xml.contains("date-stamp="));

        sendRequest(DELETE, url, 200);
        xml = sendRequest(GET, url, 204);
    }

    @Test
    public void testNodes() throws Exception {
        createRequisition();

        String url = "/requisitions/pending/test/nodes";

        // create a node
        sendPost(url, "<node xmlns=\"http://xmlns.opennms.org/xsd/config/model-import\" node-label=\"shoe\" parent-node-label=\"david\" foreign-id=\"1111\" />");
        
        // get list of nodes
        String xml = sendRequest(GET, url, 200);
        assertTrue(xml.contains("<node "));
        assertTrue(xml.contains("node-label="));
        assertTrue(xml.contains("count=\"2\""));
        
        // get individual node
        url = "/requisitions/pending/test/nodes/4243";
        xml = sendRequest(GET, url, 200);
        assertTrue(xml.contains("parent-node-label=\"apknd\""));
        
        // set attributes
        sendPut(url, "node-label=homo+sapien");
        xml = sendRequest(GET, url, 200);
        assertTrue(xml.contains("node-label=\"homo sapien\""));

        // delete node
        xml = sendRequest(DELETE, url, 200);
        xml = sendRequest(GET, url, 204);
    }

    @Test
    public void testNodeInterfaces() throws Exception {
        createRequisition();
        
        String base = "/requisitions/pending/test/nodes/4243/interfaces";
{'fraction_non_alphanumeric': 0.12275641025641025, 'fraction_numerical': 0.013782051282051282, 'mean_word_length': 3.3370396108408618, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 40}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6964391', 'n_tokens_mistral': 1820, 'n_tokens_neox': 1716, 'n_words': 302}