Search in sources :

Example 1 with Sample

use of com.iggroup.oss.sample.domain.Sample in project RESTdoclet by IG-Group.

the class AbstractSampleServiceTest method getAvailableRef.

/**
    * Find an available reference by adding 1 to the largest existing reference
    * number
    * 
    * @return unique reference
    */
private String getAvailableRef() {
    Long availRef = new Long(0);
    List<Sample> samples = service.findAllSamples();
    for (Sample s : samples) {
        Long ref = Long.valueOf(s.getReference());
        if (ref >= availRef) {
            availRef = ref + 1;
        }
    }
    return new SampleReference(availRef).toString();
}
Also used : SampleReference(com.iggroup.oss.sample.domain.SampleReference) Sample(com.iggroup.oss.sample.domain.Sample)

Example 2 with Sample

use of com.iggroup.oss.sample.domain.Sample in project RESTdoclet by IG-Group.

the class AbstractSampleServiceTest method testGetSampleByReference.

/**
    * Success test case for getSampleByReference
    */
@Test
public void testGetSampleByReference() {
    try {
        Sample sample = service.getSampleByReference("00001");
        assertTrue(sample.getReference().equalsIgnoreCase("00001"));
    } catch (Exception se) {
        assertTrue(false);
    }
}
Also used : Sample(com.iggroup.oss.sample.domain.Sample) Test(org.junit.Test)

Example 3 with Sample

use of com.iggroup.oss.sample.domain.Sample in project RESTdoclet by IG-Group.

the class AbstractSampleServiceTest method testCreateSample.

/**
    * Success test case for createSample
    */
@Test
public void testCreateSample() {
    try {
        service.createSample(new Sample(getAvailableRef(), "New Sample", SampleType.BOOK));
        assertTrue(true);
    } catch (Exception e) {
        assertTrue(false);
    }
}
Also used : Sample(com.iggroup.oss.sample.domain.Sample) Test(org.junit.Test)

Example 4 with Sample

use of com.iggroup.oss.sample.domain.Sample in project RESTdoclet by IG-Group.

the class AbstractSampleServiceTest method testDeleteSample.

/**
    * Success test case for deleteSample
    */
@Test
public void testDeleteSample() {
    String tempRef = getAvailableRef();
    try {
        service.createSample(new Sample(tempRef, "New Sample", SampleType.BOOK));
        service.deleteSample(tempRef);
    } catch (Exception e) {
        assertTrue(false);
    }
    try {
        service.getSampleByReference(tempRef);
        assertTrue(false);
    } catch (Exception e) {
        assertTrue(true);
    }
}
Also used : Sample(com.iggroup.oss.sample.domain.Sample) Test(org.junit.Test)

Example 5 with Sample

use of com.iggroup.oss.sample.domain.Sample in project RESTdoclet by IG-Group.

the class SampleServiceImpl method getSampleByReference.

@Profiled
@Override
public Sample getSampleByReference(String reference) {
    Sample sample;
    sample = sampleDAO.loadSample(reference);
    return sample;
}
Also used : Sample(com.iggroup.oss.sample.domain.Sample) Profiled(org.perf4j.aop.Profiled)

Aggregations

Sample (com.iggroup.oss.sample.domain.Sample)6 Test (org.junit.Test)4 SampleReference (com.iggroup.oss.sample.domain.SampleReference)1 Profiled (org.perf4j.aop.Profiled)1