Skip to content
This repository has been archived by the owner on Jul 18, 2022. It is now read-only.

Commit

Permalink
[CLEREZZA-695] - minor refactoring to uima.metadata-generator tests
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/incubator/clerezza/trunk@1363156 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
tteofili committed Jul 18, 2012
1 parent 9bd113a commit fa2ad34
Showing 1 changed file with 20 additions and 38 deletions.
Expand Up @@ -29,57 +29,39 @@
import java.util.HashMap;
import java.util.Map;

import static org.junit.Assert.fail;

/**
* Testcase for {@link UIMABaseMetadataGenerator}
*/
public class UIMABaseMetadataGeneratorTest {
private static final String TEXT_TO_ANALYZE = "Italy, the defending champions and four-time World Cup winners, suffer a shock World Cup defeat to Slovakia, who win a remarkable game 3-2 to book their place in the last 16";

@Test
public void testConstructor() {
try {
new UIMABaseMetadataGenerator();
}
catch (Exception e) {
fail(e.getLocalizedMessage());
}
public void testConstructor() throws Exception {
new UIMABaseMetadataGenerator();
}

@Test
public void testGenerateMethodWithUnsupportedMediaType() {
try {
UIMABaseMetadataGenerator baseMetadataGenerator = new UIMABaseMetadataGenerator();
String textToAnalyze = TEXT_TO_ANALYZE;
MGraph mGraph = new SimpleMGraph();
GraphNode node = new GraphNode(new UriRef("test"), mGraph);
MediaType wrongMediaType = MediaType.valueOf("multipart/form-data; boundary=AaB03x");
baseMetadataGenerator.generate(node, textToAnalyze.getBytes(), wrongMediaType);
} catch (Exception e) {
fail(e.getLocalizedMessage());
}

public void testGenerateMethodWithUnsupportedMediaType() throws Exception {
UIMABaseMetadataGenerator baseMetadataGenerator = new UIMABaseMetadataGenerator();
String textToAnalyze = TEXT_TO_ANALYZE;
MGraph mGraph = new SimpleMGraph();
GraphNode node = new GraphNode(new UriRef("test"), mGraph);
MediaType wrongMediaType = MediaType.valueOf("multipart/form-data; boundary=AaB03x");
baseMetadataGenerator.generate(node, textToAnalyze.getBytes(), wrongMediaType);
}

@Test
public void testGenerateMethodWithsupportedMediaType() {
try {

ExternalServicesFacade externalServicesFacade = new ExternalServicesFacade();
Map<String, Object> parameterSettings = new HashMap<String, Object>();
parameterSettings.put("apikey", "04490000a72fe7ec5cb3497f14e77f338c86f2fe");
parameterSettings.put("licenseID", "g6h9zamsdtwhb93nc247ecrs");
externalServicesFacade.setParameterSetting(parameterSettings);
UIMABaseMetadataGenerator baseMetadataGenerator = new UIMABaseMetadataGenerator(externalServicesFacade);
String textToAnalyze = TEXT_TO_ANALYZE;
MGraph mGraph = new SimpleMGraph();
GraphNode node = new GraphNode(new UriRef("test"), mGraph);
baseMetadataGenerator.generate(node, textToAnalyze.getBytes(), MediaType.TEXT_PLAIN_TYPE);
} catch (Exception e) {
fail(e.getLocalizedMessage());
}

public void testGenerateMethodWithsupportedMediaType() throws Exception {
ExternalServicesFacade externalServicesFacade = new ExternalServicesFacade();
Map<String, Object> parameterSettings = new HashMap<String, Object>();
parameterSettings.put("apikey", "04490000a72fe7ec5cb3497f14e77f338c86f2fe");
parameterSettings.put("licenseID", "g6h9zamsdtwhb93nc247ecrs");
externalServicesFacade.setParameterSetting(parameterSettings);
UIMABaseMetadataGenerator baseMetadataGenerator = new UIMABaseMetadataGenerator(externalServicesFacade);
String textToAnalyze = TEXT_TO_ANALYZE;
MGraph mGraph = new SimpleMGraph();
GraphNode node = new GraphNode(new UriRef("test"), mGraph);
baseMetadataGenerator.generate(node, textToAnalyze.getBytes(), MediaType.TEXT_PLAIN_TYPE);
}

}

0 comments on commit fa2ad34

Please sign in to comment.