Skip to content
Snippets Groups Projects
Commit 27266235 authored by t.belmega@gmx.de's avatar t.belmega@gmx.de
Browse files

Fix data-dependent tests

- Adjust create script for test data
- Adjust test cases for extended test data
parent e0c3744b
No related branches found
No related tags found
No related merge requests found
......@@ -54,12 +54,11 @@ VALUES ('category-test_id_14', 'Überkategorie2', 'Eine Kategorie zum Testen der
INSERT INTO category
VALUES ('category-test_id_15', 'Überkategorie3', 'Eine Kategorie zum Testen der Superkategorie-Beziehung', NULL);
INSERT INTO category
VALUES ('category-test_id_16', 'Überkategorie4', 'Eine Kategorie zum Testen der Superkategorie-Beziehung', NULL);
VALUES ('category-test_id_16', 'Zwischenkategorie2', 'Eine Kategorie zum Testen der Superkategorie-Beziehung', 'category-test_id_13');
INSERT INTO category
VALUES ('category-test_id_17', 'Überkategorie5', 'Eine Kategorie zum Testen der Superkategorie-Beziehung', NULL);
INSERT INTO category
VALUES ('category-test_id_11', 'Cloud Speicher', 'Cloud Speicher Description', 'category-test_id_13');
INSERT INTO category VALUES ('category-test_id_12', 'Wiki', 'Wiki Description', 'category-test_id_13');
VALUES ('category-test_id_17', 'Zwischenkategorie1', 'Eine Kategorie zum Testen der Superkategorie-Beziehung', 'category-test_id_13');
INSERT INTO category VALUES ('category-test_id_11', 'Cloud Speicher', 'Cloud Speicher Description', 'category-test_id_17');
INSERT INTO category VALUES ('category-test_id_12', 'Wiki', 'Wiki Description', 'category-test_id_17');
INSERT INTO feature VALUES ('feature-test_id_21', 'Kalender anlegen', 'Kalender anlegen Description');
INSERT INTO feature VALUES ('feature-test_id_22', 'Termine teilen', 'Termine teilen Description');
......@@ -67,7 +66,10 @@ INSERT INTO feature VALUES ('feature-test_id_23', 'Nicht zugeordnetes Feature',
'Dieses Feature ist keiner Application zugeordnet. Wird für einen Lookup-Test benötigt.');
INSERT INTO application_belongs_to_category VALUES ('application-test_id_1', 'category-test_id_11');
INSERT INTO application_belongs_to_category VALUES ('application-test_id_1', 'category-test_id_12');
INSERT INTO application_belongs_to_category VALUES ('application-test_id_1', 'category-test_id_17');
INSERT INTO application_belongs_to_category VALUES ('application-test_id_2', 'category-test_id_11');
INSERT INTO application_belongs_to_category VALUES ('application-test_id_2', 'category-test_id_17');
INSERT INTO application_has_feature VALUES ('application-test_id_1', 'feature-test_id_21');
INSERT INTO application_has_feature VALUES ('application-test_id_1', 'feature-test_id_22');
......
DROP SCHEMA provider_toolup;
CREATE SCHEMA provider_toolup;
USE provider_toolup;
CREATE TABLE application (
uuid VARCHAR(64) NOT NULL,
title VARCHAR(128) NOT NULL,
description LONGTEXT,
FULLTEXT (title,description),
PRIMARY KEY (uuid)
) ENGINE=MyISAM;
CREATE TABLE category (
uuid VARCHAR(64) NOT NULL,
title VARCHAR(128) NOT NULL,
description LONGTEXT,
supercategory VARCHAR(64),
FULLTEXT (title,description),
PRIMARY KEY (uuid),
FOREIGN KEY (supercategory) REFERENCES category (uuid)
ON DELETE SET NULL
) ENGINE=MyISAM;
CREATE TABLE feature (
uuid VARCHAR(64) NOT NULL,
title VARCHAR(128) NOT NULL,
description LONGTEXT,
FULLTEXT (title,description),
PRIMARY KEY (uuid)
) ENGINE=MyISAM;
CREATE TABLE application_belongs_to_category (
application_uuid VARCHAR(64) NOT NULL,
category_uuid VARCHAR(64) NOT NULL,
PRIMARY KEY (application_uuid, category_uuid),
FOREIGN KEY (application_uuid) REFERENCES application (uuid)
ON DELETE CASCADE,
FOREIGN KEY (category_uuid) REFERENCES category (uuid)
ON DELETE CASCADE
) ENGINE=MyISAM;
CREATE TABLE application_has_feature (
application_uuid VARCHAR(64) NOT NULL,
feature_uuid VARCHAR(64) NOT NULL,
PRIMARY KEY (application_uuid, feature_uuid),
FOREIGN KEY (application_uuid) REFERENCES application (uuid)
ON DELETE CASCADE,
FOREIGN KEY (feature_uuid) REFERENCES feature (uuid)
ON DELETE CASCADE
) ENGINE=MyISAM;
INSERT INTO application VALUES ('application-test_id_1', 'Dropbox', 'Dropbox Description');
INSERT INTO application VALUES ('application-test_id_2', 'Box.UP', 'Box.UP Description');
INSERT INTO category
VALUES ('category-test_id_13', 'Überkategorie', 'Eine Kategorie zum Testen der Superkategorie-Beziehung', NULL);
INSERT INTO category
VALUES ('category-test_id_11', 'Cloud Speicher', 'Cloud Speicher Description', 'category-test_id_13');
INSERT INTO category VALUES ('category-test_id_12', 'Wiki', 'Wiki Description', 'category-test_id_13');
INSERT INTO feature VALUES ('feature-test_id_21', 'Kalender anlegen', 'Kalender anlegen Description');
INSERT INTO feature VALUES ('feature-test_id_22', 'Termine teilen', 'Termine teilen Description');
INSERT INTO feature VALUES ('feature-test_id_23', 'Nicht zugeordnetes Feature', 'Dieses Feature ist keiner Application zugeordnet. Wird für einen Lookup-Test benötigt.');
INSERT INTO application_belongs_to_category VALUES ('application-test_id_1', 'category-test_id_11');
INSERT INTO application_belongs_to_category VALUES ('application-test_id_2', 'category-test_id_11');
INSERT INTO application_has_feature VALUES ('application-test_id_1', 'feature-test_id_21');
INSERT INTO application_has_feature VALUES ('application-test_id_1', 'feature-test_id_22');
INSERT INTO application_has_feature VALUES ('application-test_id_2', 'feature-test_id_21');
\ No newline at end of file
......@@ -23,7 +23,7 @@ public class DatabaseControllerForCategoryTest extends AbstractDatabaseTest {
Category cat = (Category) db.load(CATEGORY_TEST_ID_11);
//assert
assertEquals(CATEGORY_TEST_ID_13, cat.getSuperCategory());
assertEquals(CATEGORY_TEST_ID_17, cat.getSuperCategory());
}
@Test
......@@ -32,7 +32,7 @@ public class DatabaseControllerForCategoryTest extends AbstractDatabaseTest {
Collection<String> expectedSubCategories = Arrays.asList(CATEGORY_TEST_ID_11, CATEGORY_TEST_ID_12);
//act
Category cat = (Category) db.load(CATEGORY_TEST_ID_13);
Category cat = (Category) db.load(CATEGORY_TEST_ID_17);
//assert
assertCollectionEquals(expectedSubCategories, cat.getSubCategories());
......@@ -41,7 +41,7 @@ public class DatabaseControllerForCategoryTest extends AbstractDatabaseTest {
@Test
public void testThatCategoriesWithApplicationAreLoadedFromDB() throws Exception {
//arrange
Collection<String> expectedCategories = Arrays.asList(CATEGORY_TEST_ID_11);
Collection<String> expectedCategories = Arrays.asList(CATEGORY_TEST_ID_11, CATEGORY_TEST_ID_12, CATEGORY_TEST_ID_17);
//act
Map<String, BusinessObject> loadedCats = db.loadAllCategoriesWithApplication();
......@@ -53,7 +53,7 @@ public class DatabaseControllerForCategoryTest extends AbstractDatabaseTest {
@Test
public void testThatTopLevelCategoriesAreLoadedFromDB() throws Exception {
//arrange
Collection<String> expectedCategories = Arrays.asList(CATEGORY_TEST_ID_13);
Collection<String> expectedCategories = Arrays.asList(CATEGORY_TEST_ID_13, CATEGORY_TEST_ID_14, CATEGORY_TEST_ID_15);
//act
Map<String, BusinessObject> loadedCats = db.loadTopLevelCategories();
......
package de.unipotsdam.cs.toolup.database;
import de.unipotsdam.cs.toolup.model.BusinessObject;
import org.testng.annotations.Test;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
import static de.unipotsdam.cs.toolup.model.BusinessObjectTest.APPLICATION_TEST_ID_1;
import static de.unipotsdam.cs.toolup.model.BusinessObjectTest.APPLICATION_TEST_ID_2;
import static de.unipotsdam.cs.toolup.util.AssertionUtil.assertCollectionEquals;
public class FullTextSearchTest extends AbstractDatabaseTest {
// /**
// * Full text search for "Dropbox" should return only APP_1, which has the search string as app title and in app description.
// * @throws Exception
// */
// @Test
// public void testThatFullTextSearchMatchesAppTitel() throws Exception {
// //arrange
// Collection<String> expectedAppIDs = Arrays.asList(APPLICATION_TEST_ID_1);
//
// //act
// Map<String, BusinessObject> loadedApps = db.doFullTextSearch("Dropbox");
//
// //assert
// assertCollectionEquals(expectedAppIDs, loadedApps.keySet());
// }
//
// /**
// * Full text search for "description" should return APP_1 and APP_2, which have the search string in their description.
// * @throws Exception
// */
// @Test
// public void testThatFullTextSearchMatchesAppDescription() throws Exception {
// //arrange
// Collection<String> expectedAppIDs = Arrays.asList(APPLICATION_TEST_ID_1, APPLICATION_TEST_ID_2);
//
// //act
// Map<String, BusinessObject> loadedApps = db.doFullTextSearch("description");
//
// //assert
// assertCollectionEquals(expectedAppIDs, loadedApps.keySet());
// }
//
// /**
// * Full text search for "Kalender" should return APP_1 and APP_2, which have FEAT_21 with the search string in its title.
// * @throws Exception
// */
// @Test
// public void testThatFullTextSearchMatchesFeatureTitel() throws Exception {
// //arrange
// Collection<String> expectedAppIDs = Arrays.asList(APPLICATION_TEST_ID_1, APPLICATION_TEST_ID_2);
//
// //act
// Map<String, BusinessObject> loadedApps = db.doFullTextSearch("Kalender");
//
// //assert
// assertCollectionEquals(expectedAppIDs, loadedApps.keySet());
// }
//
// /**
// * Full text search for "teilen " should return only APP_1, which has FEAT_22 with the search string in its description.
// * @throws Exception
// */
// @Test
// public void testThatFullTextSearchMatchesFeatureDescription() throws Exception {
// //arrange
// Collection<String> expectedAppIDs = Arrays.asList(APPLICATION_TEST_ID_1);
//
// //act
// Map<String, BusinessObject> loadedApps = db.doFullTextSearch("teilen ");
//
// //assert
// assertCollectionEquals(expectedAppIDs, loadedApps.keySet());
// }
/**
* Full text search for "Dropbox" should return only APP_1, which has the search string as app title and in app description.
* @throws Exception
*/
@Test
public void testThatFullTextSearchMatchesAppTitel() throws Exception {
//arrange
Collection<String> expectedAppIDs = Arrays.asList(APPLICATION_TEST_ID_1);
//act
Map<String, BusinessObject> loadedApps = db.doFullTextSearch("Dropbox");
//assert
assertCollectionEquals(expectedAppIDs, loadedApps.keySet());
}
/**
* Full text search for "description" should return APP_1 and APP_2, which have the search string in their description.
* @throws Exception
*/
@Test
public void testThatFullTextSearchMatchesAppDescription() throws Exception {
//arrange
Collection<String> expectedAppIDs = Arrays.asList(APPLICATION_TEST_ID_1, APPLICATION_TEST_ID_2);
//act
Map<String, BusinessObject> loadedApps = db.doFullTextSearch("description");
//assert
assertCollectionEquals(expectedAppIDs, loadedApps.keySet());
}
/**
* Full text search for "Kalender" should return APP_1 and APP_2, which have FEAT_21 with the search string in its title.
* @throws Exception
*/
@Test
public void testThatFullTextSearchMatchesFeatureTitel() throws Exception {
//arrange
Collection<String> expectedAppIDs = Arrays.asList(APPLICATION_TEST_ID_1, APPLICATION_TEST_ID_2);
//act
Map<String, BusinessObject> loadedApps = db.doFullTextSearch("Kalender");
//assert
assertCollectionEquals(expectedAppIDs, loadedApps.keySet());
}
/**
* Full text search for "teilen " should return only APP_1, which has FEAT_22 with the search string in its description.
* @throws Exception
*/
@Test
public void testThatFullTextSearchMatchesFeatureDescription() throws Exception {
//arrange
Collection<String> expectedAppIDs = Arrays.asList(APPLICATION_TEST_ID_1);
//act
Map<String, BusinessObject> loadedApps = db.doFullTextSearch("teilen ");
//assert
assertCollectionEquals(expectedAppIDs, loadedApps.keySet());
}
}
......@@ -23,6 +23,10 @@ public class BusinessObjectTest {
public static final String CATEGORY_TEST_ID_11 = "category-test_id_11";
public static final String CATEGORY_TEST_ID_12 = "category-test_id_12";
public static final String CATEGORY_TEST_ID_13 = "category-test_id_13";
public static final String CATEGORY_TEST_ID_14 = "category-test_id_14";
public static final String CATEGORY_TEST_ID_15 = "category-test_id_15";
public static final String CATEGORY_TEST_ID_16 = "category-test_id_16";
public static final String CATEGORY_TEST_ID_17 = "category-test_id_17";
public static final String CATEGORY_TEST_ID_19 = "category-test_id_19";
public static final String PROVIDE_SAMPLE_IDS = "provideSampleIds";
public static final String PROVIDE_BOS_TO_COMPARE = "provideBOsToCompare";
......
package de.unipotsdam.cs.toolup.ws.beans;
import de.unipotsdam.cs.toolup.model.BusinessObject;
import de.unipotsdam.cs.toolup.model.BusinessObjectFactory;
import de.unipotsdam.cs.toolup.model.Category;
import org.json.JSONObject;
import org.testng.annotations.Test;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.*;
import static de.unipotsdam.cs.toolup.model.BusinessObjectTest.*;
import static de.unipotsdam.cs.toolup.util.AssertionUtil.assertCollectionEquals;
......@@ -20,13 +20,14 @@ public class CategoryBeanTest {
@Test
public void testThatCategoryBeanHasSuperCategoryField() throws Exception {
//arrange
String expectedSuperCategoryId = CATEGORY_TEST_ID_13;
String expectedSuperCategoryId = CATEGORY_TEST_ID_17;
//act
CategoryBean bean = CategoryBean.getBean(CATEGORY_TEST_ID_11);
//assert
assertEquals(expectedSuperCategoryId, bean.getSuperCategory());
JSONObject superCategory = new JSONObject(bean.getSuperCategory());
assertEquals(expectedSuperCategoryId, superCategory.getString(JSON_KEY_ID));
}
@Test
......@@ -35,10 +36,16 @@ public class CategoryBeanTest {
Collection<String> expectedSubcategoryIDs = Arrays.asList(CATEGORY_TEST_ID_11, CATEGORY_TEST_ID_12);
//act
CategoryBean bean = CategoryBean.getBean(CATEGORY_TEST_ID_13);
CategoryBean bean = CategoryBean.getBean(CATEGORY_TEST_ID_17);
//assert
assertCollectionEquals(expectedSubcategoryIDs, bean.getSubCategories());
List<String> actualSubcategoryIDs = new LinkedList<>();
for (String subCatRepresentation: bean.getSubCategories()) {
JSONObject cat = new JSONObject(subCatRepresentation);
actualSubcategoryIDs.add(cat.getString(JSON_KEY_ID));
}
assertCollectionEquals(expectedSubcategoryIDs, actualSubcategoryIDs);
}
@Test
......
......@@ -17,7 +17,11 @@ public class CategoryResourceTest {
Collection<CategoryBean> expectedCats = Arrays.asList(
CategoryBean.getBean(CATEGORY_TEST_ID_11),
CategoryBean.getBean(CATEGORY_TEST_ID_12),
CategoryBean.getBean(CATEGORY_TEST_ID_13)
CategoryBean.getBean(CATEGORY_TEST_ID_13),
CategoryBean.getBean(CATEGORY_TEST_ID_14),
CategoryBean.getBean(CATEGORY_TEST_ID_15),
CategoryBean.getBean(CATEGORY_TEST_ID_16),
CategoryBean.getBean(CATEGORY_TEST_ID_17)
);
//act
......@@ -31,7 +35,9 @@ public class CategoryResourceTest {
public void testThatCategoryResourceReturnsAllCategoriesWithApplications() throws Exception {
//arrange
Collection<CategoryBean> expectedCats = Arrays.asList(
CategoryBean.getBean(CATEGORY_TEST_ID_11)
CategoryBean.getBean(CATEGORY_TEST_ID_11),
CategoryBean.getBean(CATEGORY_TEST_ID_12),
CategoryBean.getBean(CATEGORY_TEST_ID_17)
);
//act
......@@ -45,7 +51,9 @@ public class CategoryResourceTest {
public void testThatCategoryResourceReturnsTopLevelCategories() throws Exception {
//arrange
Collection<CategoryBean> expectedCats = Arrays.asList(
CategoryBean.getBean(CATEGORY_TEST_ID_13)
CategoryBean.getBean(CATEGORY_TEST_ID_13),
CategoryBean.getBean(CATEGORY_TEST_ID_14),
CategoryBean.getBean(CATEGORY_TEST_ID_15)
);
//act
......
......@@ -9,6 +9,7 @@ import java.util.Collection;
import static de.unipotsdam.cs.toolup.model.BusinessObjectTest.FEATURE_TEST_ID_21;
import static de.unipotsdam.cs.toolup.model.BusinessObjectTest.FEATURE_TEST_ID_22;
import static de.unipotsdam.cs.toolup.model.BusinessObjectTest.FEATURE_TEST_ID_23;
public class FeatureResourceTest {
......@@ -18,7 +19,8 @@ public class FeatureResourceTest {
//arrange
Collection<FeatureBean> expectedFeats = Arrays.asList(
FeatureBean.getBean(FEATURE_TEST_ID_21),
FeatureBean.getBean(FEATURE_TEST_ID_22)
FeatureBean.getBean(FEATURE_TEST_ID_22),
FeatureBean.getBean(FEATURE_TEST_ID_23)
);
FeatureResource featRes = new FeatureResource();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment