Search in sources :

Example 41 with ProjectMetadata

use of com.google.refine.ProjectMetadata in project OpenRefine by OpenRefine.

the class SetProjectMetadataCommandTests method SetUp.

@BeforeMethod
public void SetUp() throws IOException {
    projMan = mock(ProjectManager.class);
    ProjectManager.singleton = projMan;
    proj = mock(Project.class);
    pw = mock(PrintWriter.class);
    request = mock(HttpServletRequest.class);
    response = mock(HttpServletResponse.class);
    SUT = new SetProjectMetadataCommand();
    ProjectMetadata metadata = new ProjectMetadata();
    metadata.setUserMetadata((ArrayNode) ParsingUtilities.mapper.readTree("[ {name: \"clientID\", display: true} ]"));
    // mock dependencies
    when(request.getParameter("project")).thenReturn(PROJECT_ID);
    when(request.getParameter("csrf_token")).thenReturn(Command.csrfFactory.getFreshToken());
    when(projMan.getProject(anyLong())).thenReturn(proj);
    when(proj.getMetadata()).thenReturn(metadata);
    try {
        when(response.getWriter()).thenReturn(pw);
    } catch (IOException e1) {
        Assert.fail();
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Project(com.google.refine.model.Project) ProjectMetadata(com.google.refine.ProjectMetadata) HttpServletResponse(javax.servlet.http.HttpServletResponse) IOException(java.io.IOException) ProjectManager(com.google.refine.ProjectManager) PrintWriter(java.io.PrintWriter) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 42 with ProjectMetadata

use of com.google.refine.ProjectMetadata in project OpenRefine by OpenRefine.

the class SqlExporterTests method SetUp.

@BeforeMethod
public void SetUp() {
    SUT = new SqlExporter();
    writer = new StringWriter();
    ProjectManager.singleton = new ProjectManagerStub();
    projectMetadata = new ProjectMetadata();
    project = new Project();
    projectMetadata.setName(TEST_PROJECT_NAME);
    ProjectManager.singleton.registerProject(project, projectMetadata);
    engine = new Engine(project);
    options = mock(Properties.class);
}
Also used : Project(com.google.refine.model.Project) SqlExporter(com.google.refine.exporters.sql.SqlExporter) ProjectManagerStub(com.google.refine.ProjectManagerStub) StringWriter(java.io.StringWriter) ProjectMetadata(com.google.refine.ProjectMetadata) Properties(java.util.Properties) Engine(com.google.refine.browsing.Engine) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 43 with ProjectMetadata

use of com.google.refine.ProjectMetadata in project OpenRefine by OpenRefine.

the class XlsExporterTests method SetUp.

@BeforeMethod
public void SetUp() {
    SUT = new XlsExporter(false);
    stream = new ByteArrayOutputStream();
    ProjectManager.singleton = new ProjectManagerStub();
    projectMetadata = new ProjectMetadata();
    project = new Project();
    projectMetadata.setName(TEST_PROJECT_NAME);
    ProjectManager.singleton.registerProject(project, projectMetadata);
    engine = new Engine(project);
    options = mock(Properties.class);
}
Also used : Project(com.google.refine.model.Project) ProjectManagerStub(com.google.refine.ProjectManagerStub) ProjectMetadata(com.google.refine.ProjectMetadata) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Properties(java.util.Properties) Engine(com.google.refine.browsing.Engine) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 44 with ProjectMetadata

use of com.google.refine.ProjectMetadata in project OpenRefine by OpenRefine.

the class ImporterTest method setUp.

public void setUp() {
    // FIXME - should we try and use mock(Project.class); - seems unnecessary complexity
    servlet = new RefineServletStub();
    ImportingManager.initialize(servlet);
    project = new Project();
    metadata = new ProjectMetadata();
    ImportingJob spiedJob = ImportingManager.createJob();
    job = Mockito.spy(spiedJob);
    when(job.getRetrievalRecord()).thenReturn(ParsingUtilities.mapper.createObjectNode());
    options = Mockito.mock(ObjectNode.class);
}
Also used : Project(com.google.refine.model.Project) RefineServletStub(com.google.refine.RefineServletStub) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ProjectMetadata(com.google.refine.ProjectMetadata) ImportingJob(com.google.refine.importing.ImportingJob)

Example 45 with ProjectMetadata

use of com.google.refine.ProjectMetadata in project OpenRefine by OpenRefine.

the class ProjectMetadataTests method serializeProjectMetadata.

@Test
public void serializeProjectMetadata() throws IOException {
    ProjectMetadata metadata = ParsingUtilities.mapper.readValue(jsonSaveMode, ProjectMetadata.class);
    TestUtils.isSerializedTo(metadata, jsonNonSaveMode);
    TestUtils.isSerializedTo(metadata, jsonSaveMode, true);
}
Also used : ProjectMetadata(com.google.refine.ProjectMetadata) Test(org.testng.annotations.Test)

Aggregations

ProjectMetadata (com.google.refine.ProjectMetadata)48 Project (com.google.refine.model.Project)34 BeforeMethod (org.testng.annotations.BeforeMethod)21 Properties (java.util.Properties)15 File (java.io.File)12 Engine (com.google.refine.browsing.Engine)11 IOException (java.io.IOException)9 ServletException (javax.servlet.ServletException)7 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)6 ProjectManagerStub (com.google.refine.ProjectManagerStub)6 Test (org.testng.annotations.Test)6 StringWriter (java.io.StringWriter)5 JSONObject (org.json.JSONObject)5 ImportingJob (com.google.refine.importing.ImportingJob)4 Column (com.google.refine.model.Column)4 ProjectManagerStub (com.google.refine.tests.ProjectManagerStub)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 SeparatorBasedImporter (com.google.refine.importers.SeparatorBasedImporter)3 BeforeTest (org.testng.annotations.BeforeTest)3 ProjectManager (com.google.refine.ProjectManager)2