/*
 * Copyright 2015-2016 Red Hat, Inc, and individual contributors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jboss.hal.testsuite.test.configuration.interfce;

import org.jboss.arquillian.core.api.annotation.Inject;
import org.jboss.arquillian.graphene.page.Page;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.hal.testsuite.Console;
import org.jboss.hal.testsuite.creaper.ManagementClientProvider;
import org.jboss.hal.testsuite.creaper.ResourceVerifier;
import org.jboss.hal.testsuite.fragment.FormFragment;
import org.jboss.hal.testsuite.fragment.HeaderBreadcrumbFragment;
import org.jboss.hal.testsuite.page.configuration.InterfacePage;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.wildfly.extras.creaper.core.online.OnlineManagementClient;
import org.wildfly.extras.creaper.core.online.operations.Operations;
import org.wildfly.extras.creaper.core.online.operations.Values;

import static org.jboss.hal.dmr.ModelDescriptionConstants.INET_ADDRESS;
import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
import static org.jboss.hal.testsuite.test.configuration.interfce.InterfaceFixtures.LOCALHOST;
import static org.jboss.hal.testsuite.test.configuration.interfce.InterfaceFixtures.UPDATE;
import static org.jboss.hal.testsuite.test.configuration.interfce.InterfaceFixtures.interfaceAddress;
import static org.junit.Assert.assertEquals;

@RunWith(Arquillian.class)
public class InterfaceApplicationTest {

    private static final OnlineManagementClient client = ManagementClientProvider.createOnlineManagementClient();
    private static final Operations operations = new Operations(client);

    @BeforeClass
    public static void beforeClass() throws Exception {
        operations.add(interfaceAddress(UPDATE), Values.empty().and(INET_ADDRESS, LOCALHOST));
    }

    @AfterClass
    public static void tearDown() throws Exception {
        operations.removeIfExists(interfaceAddress(UPDATE));
    }


    @Inject private Console console;
    @Page private InterfacePage page;
    private FormFragment form;

    @Before
    public void setUp() throws Exception {
        page.navigate(NAME, UPDATE);
        form = page.getForm();
    }

    @Test
    public void read() throws Exception {
        assertEquals(HeaderBreadcrumbFragment.abbreviate(UPDATE), console.header().breadcrumb().lastValue());
        assertEquals(UPDATE, form.value(NAME));
    }

    @Test
    public void update() throws Exception {
        form.edit();
        form.text(INET_ADDRESS, "127.0.0.2");
        form.save();

        console.verifySuccess();
        new ResourceVerifier(interfaceAddress(UPDATE), client)
                .verifyAttribute(INET_ADDRESS, "127.0.0.2");
    }
}

@@ -907,40 +907,22 @@
 ite.
-creaper.ManagementClientProvider
+CrudOperations
 ;%0Aim
@@ -958,30 +958,38 @@
 creaper.
-ResourceVerifi
+ManagementClientProvid
 er;%0Aimpo
@@ -2591,16 +2591,57 @@
 onsole;%0A
+    @Inject private CrudOperations crud;%0A
     @Pag
@@ -2670,16 +2670,16 @@
 e page;%0A
-
     priv
@@ -2864,33 +2864,16 @@
 d read()
- throws Exception
  %7B%0A     
@@ -3098,218 +3098,52 @@
     
-form.edit();%0A        form.text(INET_ADDRESS, %22127.0.0.2%22);%0A        form.save();%0A%0A        console.verifySuccess();%0A        new ResourceVerifier(interfaceAddress(UPDATE), client)%0A                .verifyAttribute(
+crud.update(interfaceAddress(UPDATE), form, 
 INET

Use CrudOperations in interface tests