<commit_before>/**
 * 
 */
package eu.dzhw.fdz.metadatamanagement.data.common.aggregations;

import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;

import org.junit.Test;

/**
 * @author <NAME>
 *
 */
public class BucketTest {
  
  @Test
  public void testSetter(){
    //Arrange
    Bucket bucket = new Bucket("Key1", 0L);
    
    //Act
    bucket.setKey("Key2");
    bucket.setDocCount(1L);
    
    //Assert
    assertThat(bucket.getKey(), is("Key2"));
    assertThat(bucket.getDocCount(), is(1L));
  }
  
  @Test
  public void testHashCode(){
    //Arrange
    Bucket bucket = new Bucket("Key1", 0L);
    
    //Act
    
    //Assert
    assertThat(bucket.hashCode(), not(0));
  }
  
  @Test
  public void testEquals(){
    Bucket bucket = new Bucket("Key1", 0L);
    Bucket bucket2 = new Bucket("Key2", 1L);
    
    //Act
    boolean checkSame = bucket.equals(bucket);
    boolean checkNull = bucket.equals(null);
    boolean checkOtherClass = bucket.equals(new Object());
    boolean checkDifferent = bucket.equals(bucket2);
    
    //Assert
    assertEquals(true, checkSame);
    assertEquals(false, checkNull);
    assertEquals(false, checkOtherClass);
    assertEquals(false, checkDifferent);
  }
}<commit_msg>#5 Added tests for equality with differing docCount<commit_after>/**
 * 
 */
package eu.dzhw.fdz.metadatamanagement.data.common.aggregations;

import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;

import org.junit.Test;

/**
 * @author <NAME>
 *
 */
public class BucketTest {

  @Test
  public void testSetter() {
    // Arrange
    Bucket bucket = new Bucket("Key1", 0L);

    // Act
    bucket.setKey("Key2");
    bucket.setDocCount(1L);

    // Assert
    assertThat(bucket.getKey(), is("Key2"));
    assertThat(bucket.getDocCount(), is(1L));
  }

  @Test
  public void testHashCode() {
    // Arrange
    Bucket bucket = new Bucket("Key1", 0L);

    // Act

    // Assert
    assertThat(bucket.hashCode(), not(0));
  }

  @Test
  public void testEquals() {
    Bucket bucket = new Bucket("Key1", 0L);
    Bucket bucket2 = new Bucket("Key2", 1L);

    // Act
    boolean checkSame = bucket.equals(bucket);
    boolean checkNull = bucket.equals(null);
    boolean checkOtherClass = bucket.equals(new Object());
    boolean checkDifferent = bucket.equals(bucket2);

    // Assert
    assertEquals(true, checkSame);
    assertEquals(false, checkNull);
    assertEquals(false, checkOtherClass);
    assertEquals(false, checkDifferent);
  }

  @Test
  public void testEqualsWithSameKeyButDifferentDocCount() {
    Bucket bucket = new Bucket("Key1", 0L);
    Bucket bucket2 = new Bucket("Key1", 1L);

    // Act
    boolean checkSame = bucket.equals(bucket2);

    // Assert
    assertEquals(true, checkSame);
  }

  @Test
  public void testHashCodeWithSameKeyButDifferentDocCount() {
    Bucket bucket = new Bucket("Key1", 0L);
    Bucket bucket2 = new Bucket("Key1", 1L);

    // Act
    boolean checkSame = bucket.hashCode() == bucket2.hashCode();

    // Assert
    assertEquals(true, checkSame);
  }
}
{'fraction_non_alphanumeric': 0.1339066339066339, 'fraction_numerical': 0.013206388206388206, 'mean_word_length': 3.2189119170984455, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6724513', 'n_tokens_mistral': 1072, 'n_tokens_neox': 1025, 'n_words': 232}