/*
* Copyright 2008 Lars Heuer (heuer[at]semagia.com). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.semagia.atomico.server.feed.impl;
import java.net.URI;
import com.semagia.atomico.server.dm.ICollectionInfo;
import com.semagia.atomico.server.dm.impl.AbstractDataModelTestCase;
import com.semagia.atomico.server.dm.impl.CollectionInfo;
import com.semagia.atomico.server.feed.impl.IOverviewFeed.ICollectionEntry;
/**
* Tests against the {@link OverviewFeed}.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
*/
public class TestOverviewFeed extends AbstractDataModelTestCase {
public void testEntry() {
final OverviewFeed feed = new OverviewFeed("id", "title", now());
assertTrue(feed.getEntries().isEmpty());
final String linkAdr = "http://www.semagia.com/link";
final URI link = URI.create(linkAdr);
final String id = "http://www.semagia.com/test";
final String title = "title";
final long updated = now();
final ICollectionInfo collInfo = new CollectionInfo(id, title, updated, "collId");
feed.addEntry(collInfo, link);
assertEquals(1, feed.getEntries().size());
final ICollectionEntry entry = feed.getEntries().iterator().next();
assertNotNull(entry);
assertEquals(id, entry.getId());
assertEquals(title, entry.getTitle());
assertEquals(linkAdr, entry.getLink());
assertEquals(updated, entry.getUpdated());
}
public void testIllegalEntry() {
final OverviewFeed feed = new OverviewFeed("id", "title", now());
try {
feed.addEntry(null);
fail("feed.addEntry(null) is illegal");
}
catch (IllegalArgumentException ex) {
// noop.
}
try {
feed.addEntry(null, URI.create("http://www.semagia.com/"));
fail("feed.addEntry(null, uri) is illegal");
}
catch (IllegalArgumentException ex) {
// noop.
}
final String id = "http://www.semagia.com/test";
final String title = "title";
final long updated = now();
final ICollectionInfo collInfo = new CollectionInfo(id, title, updated, "collId");
try {
feed.addEntry(collInfo, null);
fail("feed.addEntry(info, null) is illegal");
}
catch (IllegalArgumentException ex) {
// noop.
}
}
}