### Question:
SubscriptionBuilder { public Subscription build( final long subscriptionId, final String connectionId, final SubscribeRequest request) { final SubscriptionType subscriptionType = request.getSubscriptionType(); switch (subscriptionType) { case NEW_BLOCK_HEADERS: { return new NewBlockHeadersSubscription( subscriptionId, connectionId, request.getIncludeTransaction()); } case LOGS: { return logsSubscription(subscriptionId, connectionId, request); } case SYNCING: { return new SyncingSubscription(subscriptionId, connectionId, subscriptionType); } case NEW_PENDING_TRANSACTIONS: default: return new Subscription( subscriptionId, connectionId, subscriptionType, request.getIncludeTransaction()); } }  Subscription build(
      final long subscriptionId, final String connectionId, final SubscribeRequest request); @SuppressWarnings("unchecked") Function<Subscription, T> mapToSubscriptionClass(final Class<T> clazz);  }### Answer:
@Test public void shouldBuildLogsSubscriptionWhenSubscribeRequestTypeIsLogs() { final FilterParameter filterParameter = filterParameter(); final SubscribeRequest subscribeRequest = new SubscribeRequest(SubscriptionType.LOGS, filterParameter, null, CONNECTION_ID); final LogsSubscription expectedSubscription = new LogsSubscription(1L, CONNECTION_ID, filterParameter); final Subscription builtSubscription = subscriptionBuilder.build(1L, CONNECTION_ID, subscribeRequest); assertThat(builtSubscription).isEqualToComparingFieldByField(expectedSubscription); }
@Test public void shouldBuildPrivateLogsSubscriptionWhenSubscribeRequestTypeIsPrivateLogs() { final String privacyGroupId = "ZDmkMK7CyxA1F1rktItzKFTfRwApg7aWzsTtm2IOZ5Y="; final String enclavePublicKey = "C1bVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="; final FilterParameter filterParameter = filterParameter(); final PrivateSubscribeRequest subscribeRequest = new PrivateSubscribeRequest( SubscriptionType.LOGS, filterParameter, null, CONNECTION_ID, privacyGroupId, enclavePublicKey); final PrivateLogsSubscription expectedSubscription = new PrivateLogsSubscription( 1L, CONNECTION_ID, filterParameter, privacyGroupId, enclavePublicKey); final Subscription builtSubscription = subscriptionBuilder.build(1L, CONNECTION_ID, subscribeRequest); assertThat(builtSubscription).isEqualToComparingFieldByField(expectedSubscription); }
@Test public void shouldBuildNewBlockHeadsSubscriptionWhenSubscribeRequestTypeIsNewBlockHeads() { final SubscribeRequest subscribeRequest = new SubscribeRequest(SubscriptionType.NEW_BLOCK_HEADERS, null, true, CONNECTION_ID); final NewBlockHeadersSubscription expectedSubscription = new NewBlockHeadersSubscription(1L, CONNECTION_ID, true); final Subscription builtSubscription = subscriptionBuilder.build(1L, CONNECTION_ID, subscribeRequest); assertThat(builtSubscription).isEqualToComparingFieldByField(expectedSubscription); }
@Test public void shouldBuildSubscriptionWhenSubscribeRequestTypeIsNewPendingTransactions() { final SubscribeRequest subscribeRequest = new SubscribeRequest(SubscriptionType.NEW_PENDING_TRANSACTIONS, null, null, CONNECTION_ID); final Subscription expectedSubscription = new Subscription(1L, CONNECTION_ID, SubscriptionType.NEW_PENDING_TRANSACTIONS, null); final Subscription builtSubscription = subscriptionBuilder.build(1L, CONNECTION_ID, subscribeRequest); assertThat(builtSubscription).isEqualToComparingFieldByField(expectedSubscription); }
@Test public void shouldBuildSubscriptionWhenSubscribeRequestTypeIsSyncing() { final SubscribeRequest subscribeRequest = new SubscribeRequest(SubscriptionType.SYNCING, null, null, CONNECTION_ID); final SyncingSubscription expectedSubscription = new SyncingSubscription(1L, CONNECTION_ID, SubscriptionType.SYNCING); final Subscription builtSubscription = subscriptionBuilder.build(1L, CONNECTION_ID, subscribeRequest); assertThat(builtSubscription).isEqualToComparingFieldByField(expectedSubscription); }