agave-jobs/jobs-core/src/test/java/org/iplantc/service/jobs/managers/JobManagerIT.java
/**
	 * Tests that the job status is updated (if not redundant), and a 
	 * notification is sent when the job has one.
	 * 
	 * @param originalJobStatus the status of the job prior to updating
	 * @param newJobStatus the expected status of the job after updating
	 * @param message
	 */
Tests that the job status is updated (if not redundant), and a
notification is sent when the job has one.

@param originalJobStatus the status of the job prior to updating
@param newJobStatus the expected status of the job after updating
@param message
Tests that the job status is updated ( if not redundant ) and a notification is sent when the job has one . @param originalJobStatus the status of the job prior to updating @param newJobStatus the expected status of the job after updating @param message
@Test(dataProvider="updateStatusJobStatusTypeJobStatusTypeStringProvider", enabled=false)
	public void updateStatusJobJobStatusType(JobStatusType originalJobStatus, JobStatusType newJobStatus, String notificatonEvent, String message)
	{
		Job job = null;
		try 
		{
			NotificationDao notificationDao = new NotificationDao();
			Software software = createSoftware();
			job = createJob(originalJobStatus, software);
			Notification notification = null;
			if (!StringUtils.isEmpty(notificatonEvent)) {
				notification = new Notification(job.getUuid(), job.getOwner(), notificatonEvent, "http://example.com", false);
				notificationDao.persist(notification);
			}
			JobManager.updateStatus(job, newJobStatus);
			Assert.assertEquals(job.getStatus(), newJobStatus,
					"Job status did not update after status update.");
			Assert.assertEquals(job.getErrorMessage(), newJobStatus.getDescription(),
					"Job description did not update after status update.");
			List<JobEvent> events = JobEventDao.getByJobIdAndStatus(job.getId(), job.getStatus());
			Assert.assertEquals(events.size(), 1,
					"Wrong number of events found. Expected " + 
					1 + ", found " + events.size());
			JobEvent event = events.get(0);
			Assert.assertEquals(
					event.getDescription(),
					newJobStatus.getDescription(),
					"Wrong event description found. Expected '"
							+ newJobStatus.getDescription() + "', found '"
							+ event.getDescription() + "'");
			if (originalJobStatus != newJobStatus &&
					(StringUtils.equals(notificatonEvent, newJobStatus.name()) ||
							StringUtils.equals(notificatonEvent, "*")))
			{
				int messageCount = getMessageCount(Settings.NOTIFICATION_QUEUE);
				Assert.assertEquals(messageCount, 1, "Wrong number of messages found");
				MessageQueueClient client = MessageClientFactory.getMessageClient();
				Message queuedMessage = null;
				try {
					queuedMessage = client.pop(Settings.NOTIFICATION_TOPIC,
							Settings.NOTIFICATION_QUEUE);
				} catch (Throwable e) { 
					Assert.fail("Failed to remove message from the queue. Further tests will fail.", e);
				}
				finally {
					client.delete(Settings.NOTIFICATION_TOPIC,
							Settings.NOTIFICATION_QUEUE, queuedMessage.getId());
				}
				Assert.assertNotNull(queuedMessage,
						"Null message found on the queue");
				JsonNode json = mapper.readTree(queuedMessage.getMessage());
				Assert.assertEquals(notification.getUuid(), json.get("uuid").textValue(),
						"Notification message has wrong uuid");
				Assert.assertEquals(job.getStatus().name(), json.get("event").textValue(),
						"Notification message has wrong event");
			}
			else
			{
				Assert.assertEquals(getMessageCount(Settings.NOTIFICATION_QUEUE), 0, 
						"Messages found in the queue when none should be there.");
			}
		} catch (Exception e) {
			Assert.fail(message, e);
		}
	}
@ Test ( dataProvider = "updateStatusJobStatusTypeJobStatusTypeStringProvider" , enabled = false ) public void updateStatusJobJobStatusType ( JobStatusType originalJobStatus , JobStatusType newJobStatus , String notificatonEvent , String message ) { Job job = null ; try { NotificationDao notificationDao = new NotificationDao ( ) ; Software software = createSoftware ( ) ; job = createJob ( originalJobStatus , software ) ; Notification notification = null ; if ( ! StringUtils . isEmpty ( notificatonEvent ) ) { notification = new Notification ( job . getUuid ( ) , job . getOwner ( ) , notificatonEvent , "http://example.com" , false ) ; notificationDao . persist ( notification ) ; } JobManager . updateStatus ( job , newJobStatus ) ; Assert . assertEquals ( job . getStatus ( ) , newJobStatus , "Job status did not update after status update." ) ; Assert . assertEquals ( job . getErrorMessage ( ) , newJobStatus . getDescription ( ) , "Job description did not update after status update." ) ; List < JobEvent > events = JobEventDao . getByJobIdAndStatus ( job . getId ( ) , job . getStatus ( ) ) ; Assert . assertEquals ( events . size ( ) , 1 , "Wrong number of events found. Expected " + 1 + ", found " + events . size ( ) ) ; JobEvent event = events . get ( 0 ) ; Assert . assertEquals ( event . getDescription ( ) , newJobStatus . getDescription ( ) , "Wrong event description found. Expected '" + newJobStatus . getDescription ( ) + "', found '" + event . getDescription ( ) + "'" ) ; if ( originalJobStatus != newJobStatus && ( StringUtils . equals ( notificatonEvent , newJobStatus . name ( ) ) || StringUtils . equals ( notificatonEvent , "*" ) ) ) { int messageCount = getMessageCount ( Settings . NOTIFICATION_QUEUE ) ; Assert . assertEquals ( messageCount , 1 , "Wrong number of messages found" ) ; MessageQueueClient client = MessageClientFactory . getMessageClient ( ) ; Message queuedMessage = null ; try { queuedMessage = client . pop ( Settings . NOTIFICATION_TOPIC , Settings . NOTIFICATION_QUEUE ) ; } catch ( Throwable e ) { Assert . fail ( "Failed to remove message from the queue. Further tests will fail." , e ) ; } finally { client . delete ( Settings . NOTIFICATION_TOPIC , Settings . NOTIFICATION_QUEUE , queuedMessage . getId ( ) ) ; } Assert . assertNotNull ( queuedMessage , "Null message found on the queue" ) ; JsonNode json = mapper . readTree ( queuedMessage . getMessage ( ) ) ; Assert . assertEquals ( notification . getUuid ( ) , json . get ( "uuid" ) . textValue ( ) , "Notification message has wrong uuid" ) ; Assert . assertEquals ( job . getStatus ( ) . name ( ) , json . get ( "event" ) . textValue ( ) , "Notification message has wrong event" ) ; } else { Assert . assertEquals ( getMessageCount ( Settings . NOTIFICATION_QUEUE ) , 0 , "Messages found in the queue when none should be there." ) ; } } catch ( Exception e ) { Assert . fail ( message , e ) ; } }
Tests that the job status is updated (if not redundant), and a
 notification is sent when the job has one.
Tests that the job status is updated ( if not redundant ) and a notification is sent when the job has one .
//			JobDao.persist(job); // verify status update // verify event creation // verify notification message was sent // check for messages in the queue?