package com.google.gdata.data; import static org.junit.Assert.*; import org.junit.Test; import org.mockito.Mockito; import com.google.gdata.data.Kind.Adaptor; import com.google.gdata.data.Kind.AdaptorException; public class TestKind { @Test public void isKindCategoryTest() { Category category = new Category("scheme", "term", "label"); assertFalse(Kind.isKindCategory(category)); category = new Category("http://schemas.google.com/g/2005#kind", "term", "label"); assertTrue(Kind.isKindCategory(category)); } @Test public void getKindServiceNameTest() { String invalidURL = "blablah"; String validURL = "http://schemas.google.com/g/2005#kind"; boolean exception = false; try { Kind.getKindServiceName(invalidURL); } catch(IllegalArgumentException e) { exception = true; } assertTrue(exception); exception = false; String result = null; try { result = Kind.getKindServiceName(validURL); } catch(IllegalArgumentException e) { exception = true; } assertFalse(exception); assertNotNull(result); } @Test public void getAdaptorClassTest() { String term = "http://schemas.google.com/g/2005#kind"; Kind.Adaptable adaptable = Mockito.mock(Kind.Adaptable.class); Class result = null; boolean exception = false; try { result = Kind.getAdaptorClass(term, adaptable); } catch (AdaptorException e) { exception = true; } assertFalse(exception); assertNull(result); } @Test public void getAdaptorTest() { String term = "http://schemas.google.com/g/2005#kind"; Kind.Adaptable adaptable = Mockito.mock(Kind.Adaptable.class); Adaptor result = null; boolean exception = false; try{ result = Kind.getAdaptor(term, adaptable); } catch(AdaptorException e) { exception = true; } assertFalse(exception); assertNull(result); } }