Class DatasetsPlatformsRestTest

java.lang.Object
org.glassfish.jersey.test.JerseyTest
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

@Tag("integration") public class DatasetsPlatformsRestTest extends BaseJerseyIntegrationTest5
Integration tests for GET /datasets/{dataset}/platforms, in both modes, against a real (gemdtest) database.

🛑 The point of this class is the transaction boundary, which neither of the two existing test layers crosses. ArrayDesignDaoTest covers the same three cases but runs inside BaseDatabaseTest5's own transaction, so a Hibernate session is always bound to the thread; DatasetsWebServiceTest stubs ArrayDesignService, so the real service method never executes. A read-service method missing its @Transactional is green in both and 500s in production — which is what ArrayDesignReadServiceImpl.loadOriginalPlatformValueObjectsForEE did until 69c1c11b5f: Could not obtain transaction-synchronized Session for current thread.

These tests call the handler with no transaction open on the test thread (the Jersey base class registers no TransactionalTestExecutionListener and the in-memory container has no open-session-in-view filter), so the service must open its own. Fixture setup is the one part that needs a session, and it takes one explicitly through a TransactionTemplate.

Cases, mirroring the endpoint's documented contract:

  • a switched dataset answers with the platform it was submitted on, not the one in use;
  • a dataset that was never switched answers with an empty list, not its current platform;
  • a no-op switch (recorded original == the platform in use) is excluded.
Author:
gemma
  • Constructor Details

    • DatasetsPlatformsRestTest

      public DatasetsPlatformsRestTest()
  • Method Details

    • setUpFixtures

      @BeforeEach public void setUpFixtures()
    • tearDownFixtures

      @AfterEach public void tearDownFixtures()
    • getPlatformsOriginal_namesTheSubmittedPlatform

      @Test public void getPlatformsOriginal_namesTheSubmittedPlatform()
      A real switch: ?original=true names the submitted platform, and the default mode still names the one in use.
    • getPlatformsOriginal_isTwoHundredOverHttp

      @Test public void getPlatformsOriginal_isTwoHundredOverHttp()
      The wire check, and the reason this class exists: the route answers 200 with the submitted platform in the body. With the read service's @Transactional absent this is a 500 and the body carries Could not obtain transaction-synchronized Session for current thread.
    • getPlatformsOriginal_isEmptyWhenNeverSwitched

      @Test public void getPlatformsOriginal_isEmptyWhenNeverSwitched()
      Never switched: an empty list, NOT the platform the dataset is on. Returning the current platform here would render "as originally submitted" on every dataset in the corpus.
    • getPlatformsOriginal_excludesANoopSwitch

      @Test public void getPlatformsOriginal_excludesANoopSwitch()
      A no-op switch — the original recorded as the platform already in use — is excluded, so a non-empty answer always names something that actually changed.