<commit_before><commit_msg>tests for unprocessed<commit_after>package org.smpp.util;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

public class UnprocessedTest {

	private Unprocessed unprocessed;

	@Before
	public void setup() {
		unprocessed = new Unprocessed();
	}

	@Test
	public void testInitialState() {
		assertEquals(0, unprocessed.getExpected());
		assertEquals(0, unprocessed.getLastTimeReceived());
		assertFalse(unprocessed.getHasUnprocessed());
	}

	@Test
	public void testReset() {
		unprocessed.getUnprocessed().setBuffer(new byte[] { 0x00 });
		unprocessed.setExpected(1);
		unprocessed.setHasUnprocessed(true);
		unprocessed.setLastTimeReceived(1);

		unprocessed.reset();

		assertNull(unprocessed.getUnprocessed().getBuffer());
		assertEquals(0, unprocessed.getExpected());
		assertFalse(unprocessed.getHasUnprocessed());
		// specifically, this is not reset, for reasons unknown
		assertEquals(1, unprocessed.getLastTimeReceived());
	}

	@Test
	public void testCheckWithNullBuffer() {
		unprocessed.getUnprocessed().setBuffer(null);
		unprocessed.check();
		assertFalse(unprocessed.getHasUnprocessed());
	}

	@Test
	public void testCheckWithEmptyBuffer() {
		unprocessed.getUnprocessed().setBuffer(new byte[] {});
		unprocessed.check();
		assertFalse(unprocessed.getHasUnprocessed());
	}

	@Test
	public void testCheckWithBuffer() {
		unprocessed.getUnprocessed().setBuffer(new byte[] { 0x00 });
		unprocessed.check();
		assertTrue(unprocessed.getHasUnprocessed());
	}

	@Test
	public void testSetUnprocessed() {
		unprocessed.setHasUnprocessed(true);
		assertTrue(unprocessed.getHasUnprocessed());
	}

	@Test
	public void testSetExpected() {
		unprocessed.setExpected(1234);
		assertEquals(1234, unprocessed.getExpected());
	}

	@Test
	public void testSetTimeLastReceivedWithValue() {
		unprocessed.setLastTimeReceived(1234L);
		assertEquals(1234L, unprocessed.getLastTimeReceived());
	}

	@Test
	public void testSetTimeLastReceived() {
		unprocessed.setLastTimeReceived();
		assertTrue(Math.abs(unprocessed.getLastTimeReceived() - System.currentTimeMillis()) < 5);
	}
}
{'fraction_non_alphanumeric': 0.12488262910798122, 'fraction_numerical': 0.013615023474178404, 'mean_word_length': 6.151006711409396, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7054652', 'n_tokens_mistral': 747, 'n_tokens_neox': 640, 'n_words': 110}