Package com.insightng.thirdparty.primal

Source Code of com.insightng.thirdparty.primal.ResponseValuesTest

package com.insightng.thirdparty.primal;

import static org.junit.Assert.assertEquals;

import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openrdf.model.Model;
import org.openrdf.model.URI;
import org.openrdf.model.ValueFactory;
import org.openrdf.model.impl.LinkedHashModel;
import org.openrdf.model.impl.ValueFactoryImpl;

import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.insightng.thirdparty.primal.vocabulary.ResponseKey;

public class ResponseValuesTest {

  private final ValueFactory vf = ValueFactoryImpl.getInstance();
  private final URI subject = vf.createURI("http://example.org/stub/subject");
  private final URI property = vf.createURI("http://example.org/stub/property");
  private final URI context = vf.createURI("http://example.org/stub/context");
 
  private Model model;
 
  @Before
  public void setUp() throws Exception {
    model = new LinkedHashModel();
  }

  @After
  public void tearDown() throws Exception {
  }

  @Test
  public void testProcessDateValue() {
    String dateString = "August 25, 2011 1:16:34 PM EST";
   
    Calendar c = Calendar.getInstance(TimeZone.getTimeZone("EST"));
    c.clear();
    c.set(2011, 7, 25, 13, 16, 34);
   
    testDateValue(dateString, c.getTime());
  }

  private void testDateValue(String dateString, Date expected) {
    JsonObject jsonObject = new JsonObject();
    jsonObject.add(ResponseKey.DC_DATE, new JsonPrimitive(dateString));
    Date date = ResponseValues.processDateValue(subject, property, model, context, jsonObject, ResponseKey.DC_DATE);
   
   
    assertEquals(expected, date);
  }
}
TOP

Related Classes of com.insightng.thirdparty.primal.ResponseValuesTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.