Mockito.mock(ApplicationSubmissionContext.class);
Mockito.when(appContext.getUnmanagedAM()).thenReturn(unmanaged);
RMAppAttemptImpl attempt = new RMAppAttemptImpl(attemptId, rmContext, null,
null, appContext, new YarnConfiguration(), null);
RMAppAttemptRegistrationEvent event =
Mockito.mock(RMAppAttemptRegistrationEvent.class);
Mockito.when(event.getHost()).thenReturn("h");
Mockito.when(event.getRpcport()).thenReturn(0);
Mockito.when(event.getTrackingurl()).thenReturn(url);
new RMAppAttemptImpl.AMRegisteredTransition().transition(attempt, event);
if (unmanaged) {
Assert.assertEquals(url, attempt.getTrackingUrl());
} else {
Assert.assertNotSame(url, attempt.getTrackingUrl());