Commit df469bef authored by Ricco Førgaard's avatar Ricco Førgaard

Added Level 4.

This level is about DDI lookup.
parent 8556c0e0
......@@ -13,9 +13,9 @@ import com.nesstar.api.Server;
* This tutorial will teach you to connect to a Nesstar Server.
*
* To connect to the server you need the following info:
* - URI: http://nora.nsd.uib.no
* - Username: nesstar
* - Password: nesstar
* - URI: http://nina.nsd.uib.no
* - Username: eddiTUT
* - Password: tutEDDI
*
*/
public class Level01 {
......@@ -24,6 +24,6 @@ public class Level01 {
public void connectToNesstarServer() {
Server server = null;
assertEquals("nesstar-nightly", server.getId());
assertEquals("nina", server.getId());
}
}
package com.nesstar.tutorial;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.io.IOException;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import com.nesstar.api.NotAuthorizedException;
import com.nesstar.api.Server;
import com.nesstar.api.Study;
import com.nesstar.api.User;
......@@ -28,19 +33,21 @@ public class Level03 {
/**
* Take a Bank object that knows about studies and ask
* it to get the study with the ID "foobarbaz"
*
* Note the exceptions thrown!
*/
@Test
public void getAStudyFromTheBank() {
public void getAStudyFromTheBank() throws NotAuthorizedException, IOException {
Study study = null;
assertEquals("the right label", study.getLabel());
}
/**
* Now, get the cube with the ID "cubeid".
* Now, get the cube with the ID "cubeid".
*/
@Test
public void getACube() {
public void getACube() throws NotAuthorizedException, IOException {
Cube cube = null;
assertEquals("the right cube", cube.getLabel());
......@@ -48,12 +55,23 @@ public class Level03 {
/**
* You can also get users from the bank. Find the
* one with the username "leia".
* one with the username "leia".
*/
@Test
public void getUser() {
public void getUser() throws NotAuthorizedException, IOException {
User user = null;
assertEquals("Leia", user.getName());
}
/**
* Make a list of all Studies on the server and print
* it to the console (one Study per line).
*/
@Test
public void printAllStudies() {
List<Study> allStudies = null;
assertNotNull(allStudies);
}
}
package com.nesstar.tutorial;
import static org.junit.Assert.assertEquals;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import com.nesstar.api.Server;
import com.nesstar.api.Study;
/**
* Nesstar API Tutorial Level 4
* ============================
*
* In this tutorial you will lean about retrieving
* DDI metadata from a Study.
*
* Working with metadata in the Nesstar API is mostly
* like working with XML and XPath. All references to
* DDI fields in this tutorial can be related to the
* XML document and thus translated into XPath.
*
* All references to DDI elements are also denoted by
* their index value (e.g. 4.0 for dataDscr).
*
* Remember that Nesstar currently uses DDI 1.2.2.
*
*/
public class Level04 {
private Server server;
private Study study;
/**
* Connect to the server and get the study with
* ID "some id".
*/
@Before
public void connectToServerAndGetStudy() {
}
/**
* Get the title (2.1.1.1)
*/
@Test
public void findTitle() {
String title = null;
assertEquals("Some title", title);
}
/**
* Get the ID of the data file (3.0)
*/
@Test
public void getTheFileID() {
String id = null;
assertEquals("some id", id);
}
/**
* Find the keywords (2.2.1.1) and make a list of them.
* Make sure to maintain the order.
*/
@Test
public void getKeywords() {
List<String> keywords = null;
assertEquals(4, keywords.size());
assertEquals("France", keywords.get(0));
}
/**
* Find all of the variables (4.2) and count them.
*/
@Test
public void countTheNumberOfVariables() {
int numberOfVariables = -1;
assertEquals(117, numberOfVariables);
}
/**
* Find the variable with ID "some id" using XPath lookup
* and get the contents of the labl (4.2.2) element of that
* variable.
*/
@Test
public void findSpecificVariable() {
String label = null;
assertEquals("some label", label);
}
/**
* Make a list of the categories of the variable with
* ID "Region"
*/
@Test
public void makeAListOfCategories() {
List<String> categories = null;
assertEquals(10, categories.size());
assertEquals("Galway East", categories.get(20));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment