public void testEmpty() throws Exception { Au au = new Au(); assertNull(au.getTitle()); assertNull(au.getName()); assertNull(au.getAuid()); assertNull(au.getAuidPlus()); assertNull(au.getComputedPlugin()); assertNull(au.getEdition()); assertNull(au.getEisbn()); assertNull(au.getIsbn()); assertNull(au.getPlugin()); assertNull(au.getPluginPrefix()); assertNull(au.getPluginSuffix()); assertNull(au.getProvider()); assertNull(au.getProxy()); assertNull(au.getRights()); assertNull(au.getStatus()); assertNull(au.getStatus1()); assertNull(au.getStatus2()); assertNull(au.getVolume()); assertNull(au.getYear()); assertEmpty(au.getParams()); assertEmpty(au.getNondefParams()); assertEmpty(au.getAttrs()); assertNull(au.getImplicit()); assertNull(au.getArbitraryValue(FOO_KEY)); }
public void testPlugin() throws Exception { Au au1 = new Au(); au1.put(Au.PLUGIN, PLUGIN_VALUE); assertEquals(PLUGIN_VALUE, au1.getPlugin()); assertNull(au1.getPluginPrefix()); assertNull(au1.getPluginSuffix()); assertEquals(PLUGIN_VALUE, au1.getComputedPlugin()); Au au2 = new Au(); au2.put(Au.PLUGIN_PREFIX, PLUGIN_PREFIX_VALUE); au2.put(Au.PLUGIN_SUFFIX, PLUGIN_SUFFIX_VALUE); assertNull(au2.getPlugin()); assertEquals(PLUGIN_PREFIX_VALUE, au2.getPluginPrefix()); assertEquals(PLUGIN_SUFFIX_VALUE, au2.getPluginSuffix()); assertEquals(PLUGIN_PREFIX_VALUE + PLUGIN_SUFFIX_VALUE, au2.getComputedPlugin()); // Other combinations are illegal but have the following behavior: Au au3 = new Au(); au3.put(Au.PLUGIN, PLUGIN_VALUE); au3.put(Au.PLUGIN_PREFIX, PLUGIN_PREFIX_VALUE); assertEquals(PLUGIN_VALUE, au3.getPlugin()); assertEquals(PLUGIN_PREFIX_VALUE, au3.getPluginPrefix()); assertNull(au3.getPluginSuffix()); assertEquals(PLUGIN_VALUE, au3.getComputedPlugin()); Au au4 = new Au(); au4.put(Au.PLUGIN, PLUGIN_VALUE); au4.put(Au.PLUGIN_SUFFIX, PLUGIN_SUFFIX_VALUE); assertEquals(PLUGIN_VALUE, au4.getPlugin()); assertNull(au4.getPluginPrefix()); assertEquals(PLUGIN_SUFFIX_VALUE, au4.getPluginSuffix()); assertEquals(PLUGIN_VALUE, au4.getComputedPlugin()); Au au5 = new Au(); au5.put(Au.PLUGIN_PREFIX, PLUGIN_PREFIX_VALUE); assertNull(au5.getPlugin()); assertEquals(PLUGIN_PREFIX_VALUE, au5.getPluginPrefix()); assertNull(au5.getPluginSuffix()); assertNull(au5.getComputedPlugin()); Au au6 = new Au(); au6.put(Au.PLUGIN_SUFFIX, PLUGIN_SUFFIX_VALUE); assertNull(au6.getPlugin()); assertNull(au6.getPluginPrefix()); assertEquals(PLUGIN_SUFFIX_VALUE, au6.getPluginSuffix()); assertNull(au6.getComputedPlugin()); }
public void testNesting() throws Exception { Au au1 = new Au(); au1.put(Au.EISBN, EISBN_VALUE); au1.put(String.format("param[%s]", PARAM1_KEY), PARAM1_VALUE); au1.put(FOO_KEY, FOO_VALUE); au1.setImplicit(IMPLICIT_VALUE); Au au2 = new Au(au1); au2.put(Au.ISBN, ISBN_VALUE); au2.put(String.format("nondefparam[%s]", NONDEFPARAM1_KEY), NONDEFPARAM1_VALUE); Au au3 = new Au(au2); au3.put(Au.PLUGIN, PLUGIN_VALUE); au3.put(String.format("attr[%s]", ATTR1_KEY), ATTR1_VALUE); assertEquals(EISBN_VALUE, au3.getEisbn()); assertEquals(ISBN_VALUE, au3.getIsbn()); assertEquals(PLUGIN_VALUE, au3.getPlugin()); assertEquals(PLUGIN_VALUE, au3.getComputedPlugin()); assertEquals(PARAM1_VALUE, au3.getParams().get(PARAM1_KEY)); assertEquals(NONDEFPARAM1_VALUE, au3.getNondefParams().get(NONDEFPARAM1_KEY)); assertEquals(ATTR1_VALUE, au3.getAttrs().get(ATTR1_KEY)); assertIsomorphic(Arrays.asList("implicit1", "implicit2", "implicit3"), au3.getImplicit()); assertEquals(FOO_VALUE, au3.getArbitraryValue(FOO_KEY)); assertNull(au3.getArbitraryValue("X" + FOO_KEY)); }