Package com.semagia.atomico.server.dm.impl

Source Code of com.semagia.atomico.server.dm.impl.TestFragmentInfo

/*
* 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.dm.impl;

import java.util.Arrays;
import java.util.List;

import com.semagia.atomico.MediaType;
import com.semagia.atomico.dm.IResource;
import com.semagia.atomico.dm.impl.Resource;
import com.semagia.atomico.server.dm.IFragmentInfo;

/**
*
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
*/
public class TestFragmentInfo extends AbstractDataModelTestCase {

    private static final String _ID = "id";
    private static final String _TITLE = "title";
    private static final long _UPDATED = now();
    private static final MediaType _MEDIA_TYPE = MediaType.valueOf("application/x-tm+xtm");
    private static final String _FRAGMENT_ID = "fragId";
    private static final String _SID = "http://psi.semagia.com/test";
    private static final IResource _RES = new Resource(_SID);

    private static void _testDefaultProperties(IFragmentInfo info) {
        assertEquals(_ID, info.getId());
        assertEquals(_TITLE, info.getTitle());
        assertEquals(_UPDATED, info.getUpdated());
        assertEquals(_FRAGMENT_ID, info.getFragmentId());
        final IResource res = info.getResources().iterator().next();
        assertEquals(_SID, res.getIRI());
        assertEquals(IResource.UNKNOWN, res.getKind());
        assertEquals(_RES, res);
    }

    public void testProperties() {
        IFragmentInfo info = new FragmentInfo(_ID, _TITLE, _UPDATED, _MEDIA_TYPE, _FRAGMENT_ID, _RES);
        _testDefaultProperties(info);
        assertEquals(1, info.getMediaTypes().size());
        assertEquals(_MEDIA_TYPE, info.getMediaTypes().iterator().next());
    }

    public void testProperties2() {
        final List<MediaType> mediaTypes = Arrays.asList(new MediaType[] {_MEDIA_TYPE, MediaType.valueOf("application/x-tm+snello")});
        IFragmentInfo info = new FragmentInfo(_ID, _TITLE, _UPDATED, mediaTypes, _FRAGMENT_ID, _RES);
        assertEquals(2, info.getMediaTypes().size());
        assertEquals(mediaTypes, info.getMediaTypes());
    }
}
TOP

Related Classes of com.semagia.atomico.server.dm.impl.TestFragmentInfo

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.