CreateMetacardRolloverAction extends BaseRolloverAction { @Override public MetacardImpl doAction(MetacardImpl metacard, File tempFile) throws RolloverActionException { MetacardImpl newMetacard; try { newMetacard = new MetacardImpl(findMetacardType()); } catch (MetacardCreationException e) { throw new RolloverActionException( String.format("unable to create metacard: tempFile=%s", tempFile), e); } newMetacard.setContentTypeName(Constants.MPEGTS_MIME_TYPE); return newMetacard; } CreateMetacardRolloverAction(List<MetacardType> metacardTypeList); @Override MetacardImpl doAction(MetacardImpl metacard, File tempFile); @Override String toString();  }
@Test public void testDoAction() throws RolloverActionException { MetacardType metacardType = mock(MetacardType.class); CreateMetacardRolloverAction createMetacardRolloverAction = new CreateMetacardRolloverAction(Collections.singletonList(metacardType)); MetacardImpl metacard = createMetacardRolloverAction.doAction(null, new File("a")); assertThat(metacard.getMetacardType(), is(metacardType)); assertThat(metacard.getContentTypeName(), Matchers.is(Constants.MPEGTS_MIME_TYPE)); }
@Test(expected = RolloverActionException.class) public void testException() throws RolloverActionException { CreateMetacardRolloverAction createMetacardRolloverAction = new CreateMetacardRolloverAction(Collections.emptyList()); createMetacardRolloverAction.doAction(null, new File("a")); }