class QuickFixJTemplate implements QuickFixJOperations {

	@Override
	public boolean send(Message message) {
		Assert.notNull(message, "'message' must not be null");

		SessionID sessionID = QuickFixJSessionID.quickFixJSessionIDBuilder()
				.message(message)
				.build().toSessionID();
		return doSend(message, sessionID);
	}

}

class QuickFixJTemplateTest {

	@Rule
	public MockitoRule mockitoRule;
	@Mock
	private SessionLookupHandler sessionLookupHandler;
	@Mock
	private Session session;
	@Mock
	private Message message;
	@Mock
	private DataDictionary applicationDataDictionary;
	@Mock
	private DataDictionaryProvider dataDictionaryProvider;
	private QuickFixJTemplate quickFixJTemplate;
	private String expectedBeginString;
	private String expectedSender;
	private String expectedTarget;
	private String expectedQualifier;

	@Test
	public void shouldSendMessageWithQualifier() throws FieldNotFound {

		// Given
		mockMessage(expectedBeginString, expectedSender, expectedTarget);
		mockSessionFound();

		SessionID expectedSessionID = new SessionID(expectedBeginString, expectedSender, expectedTarget, expectedQualifier);
		given(session.send(message)).willReturn(true);

		// When
		boolean sent = quickFixJTemplate.send(message, expectedQualifier);

		// Then
		assertThat(sent).isTrue();
		assertSessionID(expectedSessionID);
		assertMessageSent(expectedSender, expectedTarget);
	}

}