Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add diffblue tests #4

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.khartec.waltz.common;

import static org.junit.Assert.assertSame;
import org.junit.Test;

public class AliasesDiffblueTest {
@Test
public void registerTest() {
// Arrange
Aliases<Object> aliases = new Aliases<Object>();

// Act and Assert
assertSame(aliases, aliases.register("val", "foo", "foo", "foo"));
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.khartec.waltz.common;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import java.util.Arrays;
import org.junit.Test;

public class ArrayUtilitiesDiffblueTest {
@Test
public void initialTest() {
// Arrange, Act and Assert
assertEquals(2, ArrayUtilities.<Object>initial(new Object[]{"foo", "foo", "foo"}).length);
}

@Test
public void isEmptyTest() {
// Arrange, Act and Assert
assertFalse(ArrayUtilities.<Object>isEmpty(new Object[]{"foo", "foo", "foo"}));
}

@Test
public void lastTest() {
// Arrange, Act and Assert
assertEquals("foo", ArrayUtilities.<Object>last(new Object[]{"foo", "foo", "foo"}));
}

@Test
public void sumTest() {
// Arrange
int[] intArray = new int[8];
Arrays.fill(intArray, 1);

// Act and Assert
assertEquals(8, ArrayUtilities.sum(intArray));
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.khartec.waltz.common;

import static org.junit.Assert.assertEquals;
import org.junit.Test;

public class ChecksDiffblueTest {
@Test
public void checkNotEmptyTest() {
// Arrange, Act and Assert
assertEquals("str", Checks.checkNotEmpty("str", "message"));
}
@Test
public void checkNotNullTest() {
// Arrange, Act and Assert
assertEquals("", Checks.<Object>checkNotNull("", "message", "foo", "", "foo"));
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package com.khartec.waltz.common;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;

public class CollectionUtilitiesDiffblueTest {
@Test
public void firstTest() {
// Arrange
ArrayList<Object> objectList = new ArrayList<Object>();
objectList.add("foo");

// Act and Assert
assertEquals("foo", CollectionUtilities.<Object>first(objectList));
}

@Test
public void isEmptyTest() {
// Arrange
ArrayList<Object> objectList = new ArrayList<Object>();
objectList.add("foo");

// Act and Assert
assertFalse(CollectionUtilities.<Object>isEmpty(objectList));
}

@Test
public void notEmptyTest() {
// Arrange
ArrayList<Object> objectList = new ArrayList<Object>();
objectList.add("foo");

// Act and Assert
assertTrue(CollectionUtilities.<Object>notEmpty(objectList));
}

@Test
public void sortTest() {
// Arrange
ArrayList<Float> resultFloatList = new ArrayList<Float>();
resultFloatList.add(10.0f);

// Act
List<Float> actualSortResult = CollectionUtilities.<Float>sort(resultFloatList);

// Assert
assertEquals(1, actualSortResult.size());
assertEquals(Float.valueOf(10.0f), actualSortResult.get(0));
}

@Test
public void sumIntsTest() {
// Arrange
ArrayList<Integer> integerList = new ArrayList<Integer>();
integerList.add(1);

// Act and Assert
assertEquals(Long.valueOf(1L), CollectionUtilities.sumInts(integerList));
}

@Test
public void sumLongsTest() {
// Arrange
ArrayList<Long> resultLongList = new ArrayList<Long>();
resultLongList.add(1L);

// Act and Assert
assertEquals(Long.valueOf(1L), CollectionUtilities.sumLongs(resultLongList));
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.khartec.waltz.common;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;

public class DebugUtilitiesDiffblueTest {
@Test
public void dumpTest() {
// Arrange
HashMap<Object, Object> objectObjectMap = new HashMap<Object, Object>();
objectObjectMap.put("foo", "foo");

// Act
Map<Object, Object> actualDumpResult = DebugUtilities.<Object, Object>dump(objectObjectMap);

// Assert
assertSame(objectObjectMap, actualDumpResult);
assertEquals(1, actualDumpResult.size());
}

@Test
public void logValueTest() {
// Arrange, Act and Assert
assertEquals("result", DebugUtilities.<Object>logValue("result", "result", "foo", "result"));
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.khartec.waltz.common;

import static org.junit.Assert.assertEquals;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import org.junit.Test;

public class DigestUtilitiesDiffblueTest {
@Test
public void digestTest() throws NoSuchAlgorithmException {
// Arrange
byte[] byteArray = new byte[24];
Arrays.fill(byteArray, (byte) 88);

// Act and Assert
assertEquals("ooseQ9DejG1ltYq+oL/LANK66RQ=", DigestUtilities.digest(byteArray));
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.khartec.waltz.common;

import static org.junit.Assert.assertEquals;
import java.io.ByteArrayInputStream;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;

public class IOUtilitiesDiffblueTest {
@Test
public void getFileResourceTest() {
// Arrange and Act
Resource actualFileResource = IOUtilities.getFileResource("file.txt");

// Assert
String actualPath = ((FileSystemResource) actualFileResource).getPath();
assertEquals("file.txt", actualFileResource.getFilename());
}

@Test
public void readAsStringTest() {
// Arrange
byte[] byteArray = new byte[24];
Arrays.fill(byteArray, (byte) 88);

// Act and Assert
assertEquals("XXXXXXXXXXXXXXXXXXXXXXXX", IOUtilities.readAsString(new ByteArrayInputStream(byteArray)));
}

@Test
public void readLinesTest() {
// Arrange
byte[] byteArray = new byte[24];
Arrays.fill(byteArray, (byte) 88);

// Act
List<String> actualReadLinesResult = IOUtilities.readLines(new ByteArrayInputStream(byteArray));

// Assert
assertEquals(1, actualReadLinesResult.size());
assertEquals("XXXXXXXXXXXXXXXXXXXXXXXX", actualReadLinesResult.get(0));
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package com.khartec.waltz.common;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import java.util.ArrayList;
import org.junit.Test;

public class ListUtilitiesDiffblueTest {
@Test
public void appendTest() {
// Arrange
ArrayList<Object> objectList = new ArrayList<Object>();
objectList.add("foo");

// Act and Assert
assertEquals(2, ListUtilities.<Object>append(objectList, "foo").size());
}

@Test
public void asListTest() {
// Arrange, Act and Assert
assertEquals(3, ListUtilities.<Object>asList("foo", "foo", "foo").size());
}

@Test
public void compactTest() {
// Arrange
ArrayList<Object> objectList = new ArrayList<Object>();
objectList.add("foo");

// Act and Assert
assertEquals(1, ListUtilities.<Object>compact(objectList).size());
}

@Test
public void dropTest() {
// Arrange
ArrayList<Object> objectList = new ArrayList<Object>();
objectList.add("foo");

// Act and Assert
assertEquals(0, ListUtilities.<Object>drop(objectList, 3).size());
}

@Test
public void ensureNotNullTest() {
// Arrange
ArrayList<Object> objectList = new ArrayList<Object>();
objectList.add("foo");

// Act and Assert
assertEquals(1, ListUtilities.<Object>ensureNotNull(objectList).size());
}

@Test
public void isEmptyTest() {
// Arrange
ArrayList<Object> objectList = new ArrayList<Object>();
objectList.add("foo");

// Act and Assert
assertFalse(ListUtilities.<Object>isEmpty(objectList));
}

@Test
public void newArrayListTest() {
// Arrange, Act and Assert
assertEquals(3, ListUtilities.<Object>newArrayList("foo", "foo", "foo").size());
}

@Test
public void pushTest() {
// Arrange
ArrayList<Object> objectList = new ArrayList<Object>();
objectList.add("foo");

// Act and Assert
assertEquals(4, ListUtilities.<Object>push(objectList, "foo", "foo", "foo").size());
}

@Test
public void reverseTest() {
// Arrange
ArrayList<Object> objectList = new ArrayList<Object>();
objectList.add("foo");

// Act and Assert
assertEquals(1, ListUtilities.<Object>reverse(objectList).size());
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.khartec.waltz.common;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import java.util.HashMap;
import org.junit.Test;

public class MapBuilderDiffblueTest {
@Test
public void addTest() {
// Arrange
MapBuilder<Object, Object> mapBuilder = new MapBuilder<Object, Object>();

// Act and Assert
assertSame(mapBuilder, mapBuilder.add("k", "k"));
}

@Test
public void buildTest() {
// Arrange, Act and Assert
assertEquals(0, (new MapBuilder<Object, Object>()).build().size());
}

@Test
public void fromTest() {
// Arrange
MapBuilder<Object, Object> mapBuilder = new MapBuilder<Object, Object>();
HashMap<Object, Object> objectObjectMap = new HashMap<Object, Object>();
objectObjectMap.put("foo", "foo");

// Act and Assert
assertSame(mapBuilder, mapBuilder.from(objectObjectMap));
}
}

Loading