Added assertion in GridFSTest
This commit is contained in:
parent
f202857195
commit
c6be2af18f
@ -2,6 +2,7 @@ package org.baeldung.gridfs;
|
|||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.hamcrest.Matchers.nullValue;
|
import static org.hamcrest.Matchers.nullValue;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
@ -52,7 +53,6 @@ public class GridFSTest {
|
|||||||
metaData.put("key", "value");
|
metaData.put("key", "value");
|
||||||
InputStream inputStream = null;
|
InputStream inputStream = null;
|
||||||
String id = "";
|
String id = "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
inputStream = new FileInputStream("src/main/resources/test.png");
|
inputStream = new FileInputStream("src/main/resources/test.png");
|
||||||
id = gridFsTemplate.store(inputStream, "test.png", "image/png", metaData).getId().toString();
|
id = gridFsTemplate.store(inputStream, "test.png", "image/png", metaData).getId().toString();
|
||||||
@ -77,7 +77,6 @@ public class GridFSTest {
|
|||||||
metaData.put("key", "value");
|
metaData.put("key", "value");
|
||||||
InputStream inputStream = null;
|
InputStream inputStream = null;
|
||||||
String id = "";
|
String id = "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
inputStream = new FileInputStream("src/main/resources/test.png");
|
inputStream = new FileInputStream("src/main/resources/test.png");
|
||||||
id = gridFsTemplate.store(inputStream, "test.png", "image/png", metaData).getId().toString();
|
id = gridFsTemplate.store(inputStream, "test.png", "image/png", metaData).getId().toString();
|
||||||
@ -128,14 +127,12 @@ public class GridFSTest {
|
|||||||
assertThat(gridFSDBFiles.size(), is(2));
|
assertThat(gridFSDBFiles.size(), is(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenFileWithMetadataExist_whenDeletingFileById_thenFileWithMetadataIsDeleted() {
|
public void givenFileWithMetadataExist_whenDeletingFileById_thenFileWithMetadataIsDeleted() {
|
||||||
DBObject metaData = new BasicDBObject();
|
DBObject metaData = new BasicDBObject();
|
||||||
metaData.put("key", "value");
|
metaData.put("key", "value");
|
||||||
InputStream inputStream = null;
|
InputStream inputStream = null;
|
||||||
String id = "";
|
String id = "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
inputStream = new FileInputStream("src/main/resources/test.png");
|
inputStream = new FileInputStream("src/main/resources/test.png");
|
||||||
id = gridFsTemplate.store(inputStream, "test.png", "image/png", metaData).getId().toString();
|
id = gridFsTemplate.store(inputStream, "test.png", "image/png", metaData).getId().toString();
|
||||||
@ -162,7 +159,6 @@ public class GridFSTest {
|
|||||||
metaData.put("key", "value");
|
metaData.put("key", "value");
|
||||||
InputStream inputStream = null;
|
InputStream inputStream = null;
|
||||||
String id = "";
|
String id = "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
inputStream = new FileInputStream("src/main/resources/test.png");
|
inputStream = new FileInputStream("src/main/resources/test.png");
|
||||||
id = gridFsTemplate.store(inputStream, "test.png", "image/png", metaData).getId().toString();
|
id = gridFsTemplate.store(inputStream, "test.png", "image/png", metaData).getId().toString();
|
||||||
@ -181,6 +177,7 @@ public class GridFSTest {
|
|||||||
GridFsResource[] gridFsResource = gridFsTemplate.getResources("test*");
|
GridFsResource[] gridFsResource = gridFsTemplate.getResources("test*");
|
||||||
|
|
||||||
assertNotNull(gridFsResource);
|
assertNotNull(gridFsResource);
|
||||||
|
assertEquals(gridFsResource.length, 1);
|
||||||
assertThat(gridFsResource[0].getFilename(), is("test.png"));
|
assertThat(gridFsResource[0].getFilename(), is("test.png"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user