package org.sanelib.ils.core.activities.publisher;

import org.junit.Test;
import org.sanelib.ils.EntityIntegrationTestBase;
import org.sanelib.ils.core.activities.ActivitiProcessConstants;
import org.sanelib.ils.core.commands.publisher.AddPublisher;
import org.sanelib.ils.core.commands.publisher.UpdatePublisher;
import org.sanelib.ils.core.domain.entity.Publisher;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

public class UpdatePublisherProcessTest extends EntityIntegrationTestBase {

    @Test
    public void testUpdatePublisherProcess() throws Throwable {

        Publisher publisher = new Publisher();
        publisher.setId("1");
        publisher.setName("Publisher");
        publisher.setCity("City");
        publisher.setState("GJ");
        publisher.setCountry("Country");

        persist(publisher);

        UpdatePublisher updatePublisher = new UpdatePublisher();
        updatePublisher.setCode("1");
        updatePublisher.setName("new name");
        updatePublisher.setCity("new city");
        updatePublisher.setState("MH");
        updatePublisher.setCountry("new country");


        String result = execute(updatePublisher, ActivitiProcessConstants.Admin.UPDATE_PUBLISHER);

        assertNull(result);

        Publisher updatedPublisher = fetch(Publisher.class, updatePublisher.getCode());

        assertNotNull(publisher);

        assertEquals(updatedPublisher.getId(), updatedPublisher.getId());
        assertEquals(updatedPublisher.getName() ,updatedPublisher.getName());
        assertEquals(updatedPublisher.getCity() , updatedPublisher.getCity());
        assertEquals(updatedPublisher.getState() ,updatedPublisher.getState());
        assertEquals(updatedPublisher.getCountry() ,updatedPublisher.getCountry());
    }
}

@@ -1464,33 +1464,32 @@
 ertEquals(update
-d
 Publisher.getId(
@@ -1485,18 +1485,20 @@
 sher.get
-Id
+Code
 (), upda
@@ -1539,33 +1539,32 @@
 ertEquals(update
-d
 Publisher.getNam
@@ -1616,33 +1616,32 @@
 ertEquals(update
-d
 Publisher.getCit
@@ -1694,33 +1694,32 @@
 ertEquals(update
-d
 Publisher.getSta
@@ -1777,25 +1777,24 @@
 quals(update
-d
 Publisher.ge

Update Publisher processor test for assertion.