EC2InstanceContextImpl implements EC2InstanceContext { @Override public Optional<String> getVersionId() { return getTaupageYaml().map(TaupageYaml::getApplicationVersion).map(StringUtils::trimToNull); } EC2InstanceContextImpl(
            final CloudTrailEvent event,
            final String instanceJson,
            final ClientProvider clientProvider,
            final AmiIdProvider amiIdProvider,
            final AmiProvider amiProvider,
            final TaupageYamlProvider taupageYamlProvider,
            final String taupageNamePrefix,
            final List<String> taupageOwners,
            final KioApplicationProvider kioApplicationProvider,
            final PieroneTagProvider pieroneTagProvider,
            final ScmSourceProvider scmSourceProvider); @Override CloudTrailEvent getEvent(); @Override String getInstanceJson(); @Override String getInstanceId(); @Override T getClient(final Class<T> type); @Override ViolationBuilder violation(); @Override String getRegionAsString(); @Override Region getRegion(); @Override Optional<String> getApplicationId(); @Override Optional<String> getVersionId(); @Override Optional<String> getSource(); @Override Optional<String> getRuntime(); @Override Optional<Application> getKioApplication(); @Override Optional<String> getAmiId(); @Override Optional<Image> getAmi(); @Override Optional<Boolean> isTaupageAmi(); @Override Optional<TaupageYaml> getTaupageYaml(); @Override Optional<TagSummary> getPieroneTag(); @Override Optional<Map<String, String>> getScmSource(); @Override String getEventName(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); @Override String getAccountId();  }
@Test public void testGetVersionId() throws Exception { when(taupageYamlProviderMock.apply(any(EC2InstanceContext.class))).thenReturn(Optional.of(taupageYaml)); final EC2InstanceContext ec2InstanceContext = new EC2InstanceContextImpl( eventMock, instanceJsonMock, clientProviderMock, amiIdProviderMock, amiProviderMock, taupageYamlProviderMock, taupageNamePrefixMock, taupageOwnersMock, kioApplicationProviderMock, pieroneTagProviderMock, scmSourceProviderMock); final Optional<String> versionId = ec2InstanceContext.getVersionId(); assertThat(versionId).isPresent(); assertThat(versionId.get()).isExactlyInstanceOf(String.class); assertThat(versionId.get()).isEqualTo("10.0"); }
@Test public void TestNull() throws Exception{ taupageYaml = new TaupageYaml("fullstop", null, "Docker", "stups/fullstop:10.0"); when(taupageYamlProviderMock.apply(any(EC2InstanceContext.class))).thenReturn(Optional.of(taupageYaml)); final EC2InstanceContext ec2InstanceContext = new EC2InstanceContextImpl( eventMock, instanceJsonMock, clientProviderMock, amiIdProviderMock, amiProviderMock, taupageYamlProviderMock, taupageNamePrefixMock, taupageOwnersMock, kioApplicationProviderMock, pieroneTagProviderMock, scmSourceProviderMock); final Optional<String> versionId = ec2InstanceContext.getVersionId(); assertThat(versionId).isEmpty(); }